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 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

Recall Tampermonkey script when page location changes

Listen to the custom events used by the youtube script: window.addEventListener(“yt-navigate-start”, e => { console.log(e.type); }); window.addEventListener(“yt-navigate-finish”, e => { console.log(e.type); }); To see all these events in Chrome: use DevTools → Elements panel → Event Listeners use DevTools → Sources panel → Global Listeners

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

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

Detecting combination keypresses (Control, Alt, Shift)?

Refer to the W3C spec for keyboard events. Several boolean attributes are provided to determine if modifier keys were pressed in conjunction with whatever target key you are interested in. They are: ctrlKey     — The “Control” key was also pressed. shiftKey   — The “Shift” key was also pressed. altKey       … 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

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