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 to override the alert function with a userscript?

Update: For modern versions of Tampermonkey, Violentmonkey, Greasemonkey (but strongly recommended to avoid GM 4+): You can intercept alert() in most cases by using @run-at document-start. For example, load this script and then visit the test page: // ==UserScript== // @name _Overwrite Alert // @match *://output.jsbin.com/* // @grant none // @run-at document-start // ==/UserScript== var alrtScope; … 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 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

Storing user login/password input in a Greasemonkey script on install

Here is a framework for getting and storing login credentials.† The script prompts for the information on the very first run and stores it, encrypted, using GM_setValue(). It also adds two items to the Greasemonkey context menu to allow changing the username or password. // ==UserScript== // @name _Autologin, sensitive info framework // @include http://YOUR_SERVER.COM/YOUR_PATH/* … Read more