How to start the script by clicking the right mouse button and selecting the desired script?
I use this parameter:
@ run-at context-menu
and tried to use this feature:
gm_registermenuccommand ("Run", Start);
where start is the name of the function running program.
So how do you still run the program in this way?
Answer 1, Authority 100%
I apologize for my machine-Russian translation.
In any case, @ Run-at Context-Menu
and GM_RegisterMenuccommand ()
are not specifically designed for sharing.
The first posts the context menu item on each page. Second place – menu of the TAMPERMONKEY menu only for selected pages (as defined by the @ MATCH directive
, @ include
etc.).
Consider this TAMPERMONKEY script (which works only in Chrome browsers):
// == Userscript ==
// @Name Context-Menu Fun (fun context menu)
// @match https://ru.stackoverflow.com/tour.
// @Grant GM_REGISTERMENUCOMMAND.
// @ Run-At Context-Menu
// == / Userscript ==
Console.log ("Start Script");
GM_REGISTERMENUCOMMAND ("Run", Start);
Function start () {
Console.log ("Startup function is running.");
}
Please note that the @match
line will be ignored because @ Run-at Context-Menu
is used.
If you set this script and visit https://ru.stackoverflow.com/tour , you will see:
1) First, there is no TAMPERMONKEY menu item for this script and no messages in the console:
2) Then run the script from the context menu of the page:
3) Then you will see the TAMPERMONKEY menu item, which you can run: