“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

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

Save images to hard disk WITHOUT prompt?

It is possible when using Tampermonkey or Violentmonkey (Firefox or Chrome). Those userscript managers have added a GM_download method. You can use it like this: // ==UserScript== // @name New Userscript // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match http*://*/* // @grant GM_download // … Read more

UserScripts & Greasemonkey: calling a website’s JavaScript functions

Background Doesn’t Greasemonkey inject my extensions JavaScript already? Can someone clarify this for me please. Greasemonkey executes your scripts in a sandbox, which is a restricted environment without direct access to the JavaScript in the page. Earlier versions of Greasemonkey injected scripts directly into the page, but this introduced serious security vulnerabilities. In the old … Read more

jQuery-UI is not working in my userscript without CSS, or with customization?

The problem with userscripts and jQuery-UI is that jQUI uses CSS with lots of background images, all loaded with relative paths. EG: … url(“images/ui-bg_dots-small_35_35414f_2x2.png”) … For security reasons, that relative path will seldom work out for a userscript. This means that to use jQUI in a userscript you can either: Load the required CSS off … Read more

How to change a class CSS with a Greasemonkey/Tampermonkey script?

For this, just use the CSS cascade. Add a style sheet to the page with GM_addStyle(). Note: We use the !important flag to cover certain potential conflicts. Use @run-at document-start (or use Stylus, see below) to minimize “flicker” associated with changing styles after the initial render. A complete script: // ==UserScript== // @name _Override banner_url … Read more