Welcome to MTurk Crowd

Work on Amazon Mechanical Turk, learn from the best, and have fun doing it. Join the crowd today!

Sign Up

Which Browsers Can You Run Userscripts In, and How?

Discussion in 'Userscripts, Extensions, and Software' started by clickhappier, Jan 24, 2016.

  1. clickhappier

    clickhappier
    Expand Collapse
    ┬──┬ ノ( ゜-゜ノ)

    • Subforum Curator
    • Crowd Pleaser
    Joined:
    Jan 12, 2016
    Messages:
    727
    Likes:
    1,609
    The 'big two' are Greasemonkey for Firefox and Tampermonkey for Chrome, but there are some other lesser-known possibilities too, some of which became available relatively recently. (I originally wrote these lists in Feb 2015, the first time all these userscript-running options had been collected in one place.)

    Some userscripts might not work with some of the other browsers, particularly the more complex ones, but could happen with any of them if they try to use a command that browser doesn't support. (Try a script and see what happens; don't be surprised or complain if it doesn't work right, or expect the script authors to be willing or able to do anything about it, but you could reply here to let people know what did or didn't work for you in which of the lesser-known options below.) Also, most of the options other than Greasemonkey and Tampermonkey have no way to control the execution order for combinations of scripts that can be sensitive to that, and some don't support running scripts on content in iframes (so they won't work inside HITs, only on the surrounding MTurk page).

    Using multiple different browsers/variants that can run simultaneously allows you to do different things on or off of MTurk in separate environments, with or without having multiple computers.

    Except where specifically stated otherwise, this is talking about browsers for desktops/laptops running Windows/Mac/Linux. Mobile possibilities are more limited; the browsers available for mobile OSes that call themselves by the same names as desktop-OS browsers don't have the same features.
     
    #1 clickhappier, Jan 24, 2016
    Last edited: Jan 24, 2016
    Tribune likes this.
  2. clickhappier

    clickhappier
    Expand Collapse
    ┬──┬ ノ( ゜-゜ノ)

    • Subforum Curator
    • Crowd Pleaser
    Joined:
    Jan 12, 2016
    Messages:
    727
    Likes:
    1,609
    For desktops/laptops
    running Windows/Mac/Linux


    Firefox
    and its variants, including Pale Moon (versions newer than 24.7.2 have compatibility issues with some add-ons; and even for PM 24.x, currently the main GM add-on page will mysteriously only offer to install an older-than-necessary 0.9.22 version, but you can get the equally-compatible 1.15 from the archived versions instead), Cyberfox (64-bit), Waterfox (64-bit), Firefox Ultimate

    **Greasemonkey for Firefox** ('GM') - Mozilla Add-Ons page - website
    This is the origin of the userscripts concept, available for Firefox since 2005, still up-to-date as of 2015.

    A competing extension called Scriptish is also available, but it hasn't been updated since June 2013 and has issues, so just stick with the better-known and better-supported Greasemonkey for Firefox.


    Chrome
    and its variants, including Chromium, SRWare Iron, and Comodo Dragon (and Chromebooks)

    **Tampermonkey for Chrome** ('TM') - Chrome Web Store page - website

    From Feb 2010 / v4 through May 2014 / v35 (though it already became somewhat more difficult after July 2012 / v21), Chrome was able to run some userscripts as natively-installed pseudo-extensions without Tampermonkey being installed. But that method doesn't support some script features; and since May 2014, Chrome on Windows will disable any such pseudo-extensions (and manually-installed regular extensions) every time you restart the browser, because they didn't come from the official Chrome Web Store. Just install Tampermonkey instead, which also provides more advanced script-management options and feature support, and then install your userscripts into Tampermonkey. (Chrome on Mac and Linux aren't affected by that policy change, but you're still better off using Tampermonkey anyway.)

    A competing extension called NinjaKit (primarily intended for Safari) is also available, but it hasn't been updated since June 2013 and has issues, so just stick with the better-known and better-supported Tampermonkey for Chrome.


    Opera

    From 2012 / v15 through present, 'Opera Next' controversially became a Chrome variant. For this generation of Opera, use:
    Tampermonkey for Opera Next - Opera Add-Ons page - website

    'Opera Classic' (aka 'Opera Presto') included built-in basic support for userscripts from April 2005 / v8 through 2012 / v12 (and small updates to v12 in 2013 and 2014), through an inconvenient interface and with limited feature support. For this generation of Opera, it's better to instead use:
    ViolentMonkey for Opera (both Classic and Next) - Opera Add-Ons page - website - direct download of Opera Classic versions
    Be sure to "check the *Allow interaction with secure pages* in Privacy settings of the extension panel as this option is not ON by default and it prevents VM from working on HTTPS pages."

    ViolentMonkey supports more features than the v12 built-in script support. But on v15+, which doesn't have its own built-in scripts support, Tampermonkey supports more features than ViolentMonkey.
    Opera Classic (v12) does not support IndexedDB, a storage method used by a few of the more complex scripts, including HitDB. Expect other feature limitations too.


    Safari

    Tampermonkey for Safari - website
    Quietly released in Nov 2014; not available in Apple's official Safari extensions site, but can be downloaded from the official Tampermonkey site. Supports Safari v5 and higher, on both Mac and Windows (Safari hasn't released versions for Windows since v5.1.7 in May 2012).
    As of Feb 2015, has a minor bug where if the first website you visit after restarting Safari has one or more userscripts set up to run on it, the scripts won't load properly until you refresh the page or visit another website.
    Safari versions before v7.1 do not support IndexedDB, a storage method used by a few of the more complex scripts, including HitDB.

    Previous options for running userscripts in Safari, which were buggy and had limited feature support, included: Creammonkey (2006-2007) and GreaseKit (2007-2008) (only for Safari on Mac, up to v4; require SIMBL framework), and NinjaKit (2010-2012) (for Safari v5 on Mac and Windows).


    Internet Explorer

    GreasemonkIE - for IE7+? - website - Crossrider install page
    Released in Aug 2014. Built using the Crossrider extension framework, which says it supports IE7 and up (IE8, IE9, IE10, IE11...). The author says "I’ve accounted for some differences between Firefox and IE, but I’m sure I’ve missed a few.", so expect unknown feature limitations.

    TrixIE WPF4.5 - for IE10?, IE11 - website

    Previous options for running userscripts in Internet Explorer, which were buggy and had limited feature support/compatibility (partly their fault, partly IE's fault - particularly the older IE versions, which used more proprietary variants of Javascript commands), included: Turnabout Advanced (2005 - IE6); Trixie (2005 - IE6, but reportedly works in its limited capacity in at least IE7-IE9 too, with increased problems in IE10-IE11); Greasemonkey for IE (2006 - IE5?, IE6); and IE7Pro's IEScripts (2007-2010 - IE6, IE7, IE8).

    One of IE's particularly odd feature limitations (which I don't know if any of the above userscript-running tools build in fixes for) is that it refuses to run any Javascript containing console.log statements, which are used by many userscript authors, unless you have the Developer Tools console open at the time. Press F12 to open Dev Tools, and then you can minimize its area, or manually adjust the height as short as possible, or detach it into a separate window that can then be minimized.


    SeaMonkey
    Based on Firefox/Netscape, but has limited extension availability.

    Scriptish for SeaMonkey - Mozilla Add-Ons page - archived website
    Scriptish hasn't been updated since June 2013, the developer is non-responsive, and its website is dead as of this writing (Feb 2015). But it reportedly still works in recent SeaMonkey versions, and the only other option is unofficial:

    Greasemonkey for SeaMonkey - website
    There was previously an official Greasemonkey version that supported SeaMonkey, but that appears to no longer be the case. This unofficial modification of the official Greasemonkey for Firefox is available instead, and up-to-date as of this writing (Feb 2015). (There is also another unofficial modified version here which is VERY outdated, not recommended. An automated add-on converter tool is also available, which may or may not be helpful.)


    Maxthon
    Based on Internet Explorer, but has branched out a lot.

    ViolentMonkey for Maxthon - Maxthon Extension Center page - website
    Note: "Some of the GM_* functions may not work due to the API limitations of Maxthon.", particularly GM_setClipboard.


    QupZilla

    QupZilla has included a built-in version of GreaseMonkey since July 2012 (occasionally updated).
    Note: "some GM_ functions does not work, mainly script resources and persistent settings."


    Midori

    Midori has included built-in basic support for userscripts since at least 2011.
    Note: Apparently does NOT support scripts that @require external libraries such as Jquery, or any GM_ functions.
     
    #2 clickhappier, Jan 24, 2016
    Last edited: Jan 24, 2016
    Tribune likes this.
  3. clickhappier

    clickhappier
    Expand Collapse
    ┬──┬ ノ( ゜-゜ノ)

    • Subforum Curator
    • Crowd Pleaser
    Joined:
    Jan 12, 2016
    Messages:
    727
    Likes:
    1,609
    For mobile devices


    Mobile: Android (Smartphones and Tablets)

    Tampermonkey for Dolphin - for Android 4.0.3+ - Google Play app page - website
    Kinda-quietly released in Jan 2015. Requires the Dolphin Browser. When used on Android 4.4+, also requires Dolphin Jetpack.
    Tampermonkey for Dolphin's Play Store page says "frames are not supported" at this time; this means scripts can't affect content inside iframes such as the ones used to display HITs on MTurk.

    Opera Mobile Labs (Classic) with Extension/Add-On Support - OS version support unknown, presumably Android 1.6-4.4 - website
    This option requires enabling sideloading on your Android device, and then visit the above Opera webpage in an existing web browser on your Android device to download the APK file.
    This is a special version of Opera Mobile v12 released in April 2012, that supports installing regular Opera add-ons, including ViolentMonkey. If you run into difficulties with the more recent versions of ViolentMonkey, older versions can be downloaded here and here. A few more tips here and here.
    Opera Mobile Labs Classic does not support IndexedDB, a storage method used by a few of the more complex scripts, including HitDB. Expect other feature limitations too.

    Opera Mobile Classic - for Android 1.6-4.4 - Google Play app page
    Like the desktop Opera Classic, it has basic built-in support for userscripts, hidden deep in the settings. This guide shows how to use it, but you should point the 'User Javascript File' setting to a whole folder to allow using multiple scripts that you save in that folder, rather than pointing it to an individual script file as they show there; and select both the 'User Javascript' and 'User Javascript HTTPS' checkboxes.
    Opera Mobile Classic (v12.x) does not support IndexedDB, a storage method used by a few of the more complex scripts, including HitDB. Expect other feature limitations too.
    The non-'Classic' (newer than v12.x) version of Opera Mobile does not support userscripts.

    standalone Tampermonkey app - for Android 2.2+ - Google Play app page
    Buggy abandoned project from the Tampermonkey programmer, last updated in 2013 (he moved on to the aforementioned Dolphin project instead). Only runs the scripts in its own very-basic built-in browser, that lacks even the ability to have more than one webpage open at a time (no windows/tabs). Reportedly does NOT support localStorage, which multiple popular scripts use to save data. Some usage tips are available here.


    Mobile: Apple iOS (iPhones and iPads)

    Only with a jailbroken iPhone/iPad (there are risks/concerns regarding jailbreaking to be aware of), you can use the alternative app store Cydia to install one of these two apps:
    UserScript for Chrome - free - OS version support unknown - Cydia app info preview - Enables userscript support in Chrome for iOS. Expect IndexedDB not to work on iOS versions earlier than 8, GM_ functions likely won't work, and other unknown feature limitations.
    Userscripts Loader - costs $2.99 - for iOS 5+ - Cydia app info preview (and some tips here) - Enables userscript support in multiple iOS browsers (Safari, Chrome, et al). Expect IndexedDB not to work on iOS versions earlier than 8, GM_ functions likely won't work, and other unknown feature limitations.

    An app called WebHub Browser was previously available for iOS, but it cost several dollars, had minimal feedback available and most of what there was looked discouraging, and its only documentation was in Japanese. After several years of not being updated, it was removed from Apple's app store some time in Q2-Q3 2015.


    Also consider bookmarklets (see next post).
     
    #3 clickhappier, Jan 24, 2016
    Last edited: Jan 24, 2016
    Wildcat and Tribune like this.
  4. clickhappier

    clickhappier
    Expand Collapse
    ┬──┬ ノ( ゜-゜ノ)

    • Subforum Curator
    • Crowd Pleaser
    Joined:
    Jan 12, 2016
    Messages:
    727
    Likes:
    1,609
    Bookmarklets


    Potentially Any Browser, on Desktop or Mobile!
    Originally written in Feb 2015

    For reference: wikipedia's explanation of bookmarklets

    If you're using a computer where you can't install browser extensions/add-ons to run userscripts, or a mobile device that doesn't have a practical way for you to run userscripts otherwise, there is another option! When you execute Javascript code from within a special bookmark (create a regular bookmark, then edit its properties and replace the normal URL in the bookmark with Javascript code), it's commonly called a 'bookmarklet'. It's possible for the function of the bookmarklet's code to be temporarily embedding a whole original userscript file into the webpage you're currently viewing; this has sometimes been called a 'bookmarklet bootloader', an 'externalized bookmarklet', or a 'stub bookmarklet'. The file should be cached by your browser for multiple uses, so you hopefully won't be downloading it again every time.

    Reportedly, "Bookmarklets work with most browser (Internet Explorer, Firefox, Safari, Chrome, and Opera [etc]) and operating system (Windows, OSX, Linux/Unix, iPhone, Palm, Blackberry, etc.)". There are many limitations to this: they can't do anything to content inside frames/iframes from different sources (like HITs are), they're still **limited by what Javascript functions and storage methods your browser can support** (see above sections), and scripts that use Jquery or GM_ functions won't work (unless you do something extra, see below). You will have to run your bookmarklet/s again on each visit to each page that you want them to take effect on.

    It requires careful pre-creation of your 'bookmarklet' bookmarks, and one misplaced character will break it. Spaces are 'escaped' by replacing them with '%20'. To get the Javascript file URL to use, find your desired script on Greasyfork, right-click on the 'Install This Script' button, and select 'Copy Link Location'/'Copy Link Address' or similar. The link should end in '.user.js' (and ideally should begin with 'https://', as Greasyfork's links do, or else you'll have 'click the shield' issues when it's run on https sites like mturk). If you have personal scripts that aren't on Greasyfork, you can upload them somewhere like Dropbox and include them from there (for Dropbox, the URL should start with https://dl.dropboxusercontent.com , and end with .user.js).
    Once you have a .js URL for your desired script, use it to replace the example script URL between the double quote marks ( " " ) near the end of the appropriate bookmarklet code below.

    If you're trying to set these up on a mobile device, you may find it easier to build them on a desktop computer and then email the finished code to yourself for copying and pasting into bookmarks, or use a desktop-browser-to-mobile-browser syncing service if you have one set up; here are a few iOS tips. Ensure that all of the quote marks remain 'straight quotes' like ' or ", not the 'curly quotes'/'smart quotes' that some software may want to turn them into, those are different characters that don't work in programming.

    Also, be aware that most modern browsers no longer allow Javascript code to be effectively executed by pasting it into the address bar as an easy way of pre-testing; it has to be inside a saved bookmark. (There are some buried settings available in some browsers to re-enable it, but probably better not to mess with that for security reasons, and just make bookmarks.) This apparently has been true for Firefox since 2011/v6, Internet Explorer since at least 2011/IE9, Safari and Opera since at least early 2014... and in Chrome for at least that long, but there's a workaround for Chrome: if you manually type at least the first 'j' in 'javascript', and then paste the rest of the code, it will run. If you copy the whole thing including all of the starting 'javascript:', some browsers will strip out the whole 'javascript:' from your paste and you'll need to retype all of that word.


    This is a working example using the official Turkopticon script file. It's based on an example from a site promoting it for use in Safari for iPad, and I successfully tested it on a desktop Firefox variant and a desktop Chrome variant. There is also a Bookmarklet Bootloader Generator tool that can generate code similar to this structure.

    Code:
    javascript:void((function(d){var%20e=d.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src',"https://greasyfork.org/scripts/4391-turkopticon/code/turkopticon.user.js");d.body.appendChild(e)})(document));

    And here's a more concise way of structuring it, based on examples seen here et al, that may work for you too. It's been stated to work on Safari for iPhone/iPad, and I successfully tested it on Firefox and Chrome, as above.

    Code:
    javascript:(function(){document.body.appendChild(document.createElement('script')).src="https://greasyfork.org/scripts/4391-turkopticon/code/turkopticon.user.js";})();

    Here is an example for scripts that rely on Jquery, with conflict prevention based on this. This example uses mmmturkeybacon Enhanced HIT Information Capsule (runs on mturk preview pages).

    Code:
    javascript:(function(){if(typeof%20window.jQuery!='undefined'){f();}else{var%20c=typeof%20window.$!='undefined';var%20d=document.createElement('script');d.setAttribute('src','https://code.jquery.com/jquery-latest.min.js');document.getElementsByTagName('head')[0].appendChild(d);var%20e=15;(function(){if(typeof%20window.jQuery=='undefined'){if(--e%3E0){window.setTimeout(arguments.callee,250);}}else{f();}})();}function%20f(){document.body.appendChild(document.createElement('script')).src="https://greasyfork.org/scripts/3114-mmmturkeybacon-enhanced-hit-information-capsule/code/mmmturkeybacon%20Enhanced%20HIT%20Information%20Capsule.user.js";}})()

    Or to give userscripts that rely on GM_ functions a chance of working, there are a few library scripts available that attempt to provide other ways for some of those functions to work in some browsers, if you make a bookmarklet that loads one of them in addition to the actual userscript you want. This example code loads one of the GM_ libraries only if one isn't already loaded, and then a userscript as an example. These bookmarklets use a special version of an old userscripts.org library Greasemonkey Emulation that I uploaded on Greasyfork for https access, and to which I added a few more minor missing GM_ functions as 'stubs', so any scripts that try to use those functions at least won't terminate prematurely due to undefined functions, even though it isn't possible to actually do what it wanted. This example uses Show Captcha and Accept Button ASAP (runs on mturk preview pages).

    Code:
    javascript:(function(){if(typeof%20GM_getValue!='undefined'){f();}else{var%20d=document.createElement('script');d.setAttribute('src','https://greasyfork.org/scripts/8068-1-greasemonkey-emulation/code/1%20Greasemonkey%20Emulation.js');document.getElementsByTagName('head')[0].appendChild(d);var%20e=15;(function(){if(typeof%20GM_getValue=='undefined'){if(--e%3E0){window.setTimeout(arguments.callee,250);}}else{f();}})();}function%20f(){document.body.appendChild(document.createElement('script')).src="https://greasyfork.org/scripts/5918-mturk-show-captcha-and-accept-button-asap/code/(mTurk)%20Show%20captcha%20and%20accept%20button%20ASAP.user.js";}})()
    And here is an example combining both GM_ and Jquery. If you're unsure whether to use the basic version, the GM_ version, the Jquery version, or the GM_-and-Jquery version, it should be okay to use the GM_-and-Jquery version on all scripts (shouldn't make anything not work that wouldn't have already not been working). This example uses Great HIT Export (runs on mturk search results pages).

    Code:
    javascript:(function(){if(typeof%20window.jQuery!='undefined'){f();}else{var%20c=typeof%20window.$!='undefined';var%20d=document.createElement('script');d.setAttribute('src','https://code.jquery.com/jquery-latest.min.js');document.getElementsByTagName('head')[0].appendChild(d);var%20e=15;(function(){if(typeof%20window.jQuery=='undefined'){if(--e%3E0){window.setTimeout(arguments.callee,250);}}else{f();}})();}function%20f(){if(typeof%20GM_getValue!='undefined'){h();}else{document.getElementsByTagName('head')[0].appendChild(document.createElement('script')).src='https://greasyfork.org/scripts/8068-1-greasemonkey-emulation/code/1%20Greasemonkey%20Emulation.js';var%20g=15;(function(){if(typeof%20GM_getValue=='undefined'){if(--g%3E0){window.setTimeout(arguments.callee,250);}}else{h();}})();}}function%20h(){document.body.appendChild(document.createElement('script')).src="https://greasyfork.org/scripts/911-mturk-great-hit-export/code/MTurk%20Great%20HIT%20Export.user.js";}})()

    PS: If you're familiar enough with Javascript to want to take a closer look at bookmarklets' code, you can paste them into the Javascript Beautifier tool to 'decompress' them into readable formatting.

    PPS: There is a Bookmarklet Combiner tool available that may be of interest, if your browser can handle the potentially-quite-lengthy bookmarklets it generates.


    Also of interest: auto-refresh bookmarklet
     
    #4 clickhappier, Jan 24, 2016
    Last edited: Jan 24, 2016
    Tribune likes this.