Create a “config” or “options” page for a Greasemonkey script

There are a few libraries which provide config pages for userscripts: 1) GM_config 2) MonkeyConfig 3) GM_registerMenuCommand Submenu JS Module The usage varies per library, but typically you grant the permissions they need such as GM_getValue and GM_setValue, and require the library via the @require directive, e.g.: // ==UserScript== // @name My Userscript // @description … Read more

how to run greasemonkey script before the page content is displayed?

EDIT: This post was created prior to the implementation of the @run-at key in Greasemonkey – as noted by Blaise, from Greasemonkey 0.9.8 you may now have the script executed as soon as the page begins to load. @run-at document-start is described in the wiki as follows: Start is new as of version 0.9.8. The … Read more

Stop execution of Javascript function (client side) or tweak it

Firefox currently supports the beforescriptexecute event (as of Version 4, released on March 22, 2011)‡. With that event and the // @run-at document-start directive, Firefox and Greasemonkey now seem to do a good job intercepting specific <script> tags. This is still not possible for Chrome+Tampermonkey. For anything but Firefox+Greasemonkey, you will need to use techniques … 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

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

Fire Greasemonkey script on AJAX request

The smart way to rerun the script’s code on AJAX requests, is to focus on the key bits of the page and check for changes. For example, suppose a page contained HTML like so: <div id=”userBlather”> <div class=”comment”> Comment 1… </div> <div class=”comment”> Comment 2… </div> … </div> and you wanted the script to do … Read more

Replace remote JavaScript file with a local debugging copy using Greasemonkey or userscript

So basically, as @BrockAdams identified, there are a couple of solutions to these types of problem depending on the requirements, and they follow either 1 of 2 methods. the browser API switcharoo. The proxy based interception befiddlement. the browser API switcharoo. Both firefox and chrome support browser extensions that can take advantage of platform specific … Read more

How to determine why a Greasemonkey script is not running [duplicate]

When I was starting with user scripts, my first error was not using wildcards. // Broken: // @include https://www.example.com/ // Working: // @include https://www.example.com/* That’s the simplest way for the script to not even apply, and thus not run at all. In addition, make sure to check for syntax errors; a misplaced semicolon can prevent … Read more

tech