Why is usage of the downloadURL & updateURL keys called unusual and how do they work?

Use of those keys is discouraged mainly by Greasemonkey’s lead developer. Most others, including the Tampermonkey team feel no need for such a warning. Also note that those directives are not always required for auto-updates to work. Some reasons why he would say that it was unusual and that “most” scripts should omit it: In … Read more

How do I get Greasemonkey to click on a button that only appears after a delay?

That code has errors. Use Firefox’s error console (CtrlShiftJ) to see them. Using jslint to check your code, can be helpful too. Anyway, this is a common Greasemonkey problem. Use the waitForKeyElements() utility to handle the delayed appearance of that button. Use jQuery to simplify the code (and make it more robust and portable). So … Read more

Add a JavaScript button using Greasemonkey or Tampermonkey?

Ok, here’s a complete script that adds a live button to SO question pages1: // ==UserScript== // @name _Adding a live button // @description Adds live example button, with styling. // @match *://stackoverflow.com/questions/* // @match *://YOUR_SERVER.COM/YOUR_PATH/* // @grant GM_addStyle // ==/UserScript== /*— Create a button in a container div. It will be styled and positioned … Read more

“getElementById not a function” when trying to parse an AJAX response?

Use DOMParser() to convert responseText into a searchable DOM tree. Also, your attempts to search/use anything derived from responseText, must occur inside the onload function. Use code like this: GM_xmlhttpRequest ( { … onload: parseAJAX_ResponseHTML, … } ); function parseAJAX_ResponseHTML (respObject) { var parser = new DOMParser (); var responseDoc = parser.parseFromString (respObject.responseText, “text/html”); console.log … Read more

Error: Permission denied to access property ‘handler’

Greasemonkey 2.0 has just been pushed to all Firefox browsers set to auto-update. (GM 2 was released on June 17, 2014, but it can take a few weeks to get through the review process.) Greasemonkey 2.0 radically changed unsafeWindow handling: Backwards incompatible changes: For stability, reliability, and security the privileged sandbox has been updated to … Read more

How do I click on this button with Greasemonkey?

Here is a complete script that does that. It uses jQuery for the :contains() selector. Update: Modified script to account for reported AJAX. // ==UserScript== // @name _Click on a specific link // @include http://YOUR_SERVER.COM/YOUR_PATH/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @grant GM_addStyle // ==/UserScript== /*- The @grant directive is needed to work around … Read more

How to call Greasemonkey’s GM_ functions from code that must run in the target page scope?

To use Greasemonkey’s GM_ functions from code that must run in the page scope (Such as your timeBtn click handler), do the following: Have the page-scope code use postMessage to send the data in string format. Have the Greasemonkey script listen for the appropriate messages and call the desired GM_ function(s) with the message data. … Read more

Add parameters to the URL (redirect) via a Greasemonkey/Tampermonkey/Userscript

The script should do these things: Detect if the current URL is already to the compact site. Load the compact version of the page if necessary. Beware of “anchor” URLS (they end with “fragments” or “hashes” (#…) ) and account for them. Keep the unwanted pages out of the browser history so that the back … Read more