I am currently trying to create 3 userscripts in Tampermonkey for separate pages. Using the GUI, I can click on "Add a new script", however every time I save after making changes, it re-saves over the top of 'My Fancy New Userscript' and there doesn't seem to be any way of renaming the scripts.
Perhaps I am missing something?:)
Tampermonkey. Tampermonkey is one of the most popular browser extensions with over 10 million users. Tampermonkey is used to run so-called userscripts (sometimes also called Greasemonkey scripts) on websites.
Tampermonkey has it's own built-in editor. Just hit the Tampermonkey button and select Dashboard. To get a new script, hit the little + tab in the upper right. You'll get a nice template with an IIFE (Immediately Invoked Function Expression) that you should put all your code in to avoid global namespace pollution.
The name is set by the @name
directive. In Tampermonkey, there can never be more than one script with the same @name
1.
In fact, you should examine and change, or delete, every one of the default @
directives with each new script. Most of that is clutter (most of the time), and it's poor practice to have a script run on every page like @match http://*/*
specifies.
A good starter template is:
// ==UserScript==
// @name _YOUR_SCRIPT_NAME
// @match http://YOUR_SERVER.COM/YOUR_PATH/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @grant GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
introduced in GM 1.0. It restores the sandbox.
*/
Where you change the @name
and @match
(es) for every script.
This template also uses jQuery from the local disk (which you will want to do for any serious scripting), and is fully compatible with Greasemonkey.
1 This is actually a bit of a bug. Tampermonkey should follow the Greasemonkey model, where it's the @name
+ @namespace
combination that has to be unique.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With