17

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?:)

robmunro
  • 175
  • 1
  • 7

1 Answers1

40

The name is set by the @name directive. In Tampermonkey, there can never be more than one script with the same @name1.

Changing the name


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.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295