“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

How can I load a shared web worker with a user-script?

You can use fetch(), response.blob() to create an Blob URL of type application/javascript from returned Blob; set SharedWorker() parameter to Blob URL created by URL.createObjectURL(); utilize window.open(), load event of newly opened window to define same SharedWorker previously defined at original window, attach message event to original SharedWorker at newly opened windows. javascript was tried … Read more