HTML5 flash replacement trick

Discussion in 'PowerPC Macs' started by Wildy, Jan 5, 2013.

  1. Wildy, Jan 5, 2013
    Last edited: Jan 6, 2013

    Wildy macrumors 6502

    Jan 25, 2011
    While some websites (such as Youtube) have dedicated HTML5 versions, most other websites are still using Flash only. Interestingly, if you browse these sites on a mobile device then you'll find that they have actually been adapted to run without Flash. The premise is, using a special filter for GlimmerBlocker, we can have a system-wide setting in place which will spoof the user agent of an iPad to coax these websites into displaying Flash-free HTML5 goodness. Why are we spoofing an iPad? Well because it has a resolution similar to that of our PPC machines - the result is that we get a cleaner layout, but one which was designed for a bigger screen as opposed to a tiny mobile.

    You will need GlimmerBlocker installed and running.

    In the filters tab, add a new filter to store the rule in.

    Add a new rule and leave everything as-is except Action, which needs to be changed to Modify Request. If you only want the to view certain sites then you can add them to the Host box - you will need to duplicate the rule for each site.

    On the Request tab, copy and paste the following code:
    var ua = gb.request.headers["User-Agent"]
    ua = ua ? ua.toString() : "none"; 
    //if (ua.match(/Safari/)) // Uncomment this line if you only want a single browser to display in mobile mode
    	gb.request.headers["User-Agent"] = ["Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10"];
    If you only want to apply this rule to a single browser, then uncomment the line mentioned and change Safari to whichever browser you want it to apply to.

    You should be all good to go!

    Quite a few browsers have a user agent changer built in, but I use Stainless which does not - hence why I created this.


  2. B-G, Jan 5, 2013
    Last edited: Jan 5, 2013

    B-G macrumors regular

    Dec 14, 2011
    Excellent work! This is indeed a very cool and useful trick. I was experimenting with this myself, and the problem I was having was that I wanted to be able to enable UA spoofing only on one browser. I see that in your filter you can choose to do that when the user agent of the targeted browser matches a precise string. This is a very elegant solution. I can see only two problems with that:
    1) it seems that GlimmerBlocker won't let you alter rules in a subscribed filter, so the user will have to copy and paste the single rule in your filter in a personal one, and then uncomment the required instruction.
    2) every time the targeted browser is updated its user agent is changed, so it is necessary to manually edit the rule.
    Other than that your filter works fine. I prefer to enable UA spoofing only on selected sites (that's because on most sites I already get html5 video through ClickToPlugin in Safari/Webkit) but it's only a matter of duplicating the rule in the filter and altering the targeted URL, and that's very easy and fast to do.

    If you don't mind I would like to put a link to this thread here as a reference.
  3. Wildy, Jan 6, 2013
    Last edited: Jan 6, 2013

    Wildy thread starter macrumors 6502

    Jan 25, 2011
    Ah, that's where that thread went! I was actually looking for that so I could post this there, rather than start a new thread. But by all means, feel free.

    I didn't realize you can't change the rules of subscribed filters - I shall update the instructions. To make things easier, I could use a regex to strip out the browser name from the UA string instead of requiring a complete one - this should work fine for browser updates too.

    EDIT: Updated to reflect changes.
  4. B-G macrumors regular

    Dec 14, 2011
  5. SuperKerem macrumors 6502a


    Oct 29, 2012
    United Kingdom
  6. skateny macrumors 6502


    Jul 19, 2012
    New York, NY
    Yeah it is.

    Thanks to the OP for your good work.

    This reminds me of a work-around either on MR or somewhere else, that entailed tricking Web sites into treating your PowerPC in the way they would an iOS device. As I recall, I think Fluid was involved.

    Anyway, this is just another reason to enjoy working with PowerPCs. Stuff like this comes from years of needing to adjust to technologies that have sadly left behind some very good machines.

Share This Page