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

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

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

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