Cannot rename or create more than one user usercript script in Tampermonkey

I am currently trying to create 3 custom scripts in Tampermonkey for individual pages. Using the graphical interface, I can click “Add a new script”, however every time I save it after making changes, it again saves the top of “My Unusual new desktop”, and it seems to rename the scripts.

Maybe something is missing for me? :)

+6
source share
1 answer

The name is given 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 modify or remove each of the default @ directives with each new script. In most cases, this is a mess (in most cases), and its bad practice is that the script runs on every page, for example @match http://*/* .

Good starter template:

 // ==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 do you change @name and @match (es) for each script.

This template also uses jQuery from the local disk (which you want to do for any serious scripts) and is fully compatible with Greasemonkey.




1 Actually this is a bit of a mistake. Tampermonkey should follow the Greasemonkey model, where there should be a unique combination of @name + @namespace .

+13
source

Source: https://habr.com/ru/post/944673/


All Articles