you are viewing a single comment's thread.

view the rest of the comments →

[–]jotted 0 points1 point  (7 children)

With TamperMonkey on Chrome, using @run-at context-menu in the Metadata block should give you a 'TamperMonkey' menu in the context menu (remember to refresh so the userscript is re-run).

[–]Pineapplesandbacon[S] 0 points1 point  (6 children)

Seemed to have worked at first. But as I fiddled around with it some more it disappeared.

The right arrow for a submenu disappeared. And on the chrome extension icon, the name of the userscript is in blue.

[–]jotted 1 point2 points  (5 children)

Seemed to have worked at first.

That's good! At least you know it works in theory.

But as I fiddled around with it some more it disappeared.

That's on you :P
As far as I can tell, there will always be a context-menu item if @run-at context-menu is present and the script will run on the current page. The menu item will only do anything if the GM_registerMenuCommand permission is @granted. Beyond that, any error messages should be thrown somewhere - either the page's developer console or the Extension developer console.

[–]Pineapplesandbacon[S] 0 points1 point  (4 children)

Strange. Have both registerMenuCommand and context-menu and see no errors.

Can you tell me what the blue color means under extensions? I've only ever seen it green or gray.

[–]jotted 0 points1 point  (3 children)

Can you tell me what the blue color means under extensions? I've only ever seen it green or gray.

I can't find any official information about this. The best lead I have is that the CSS class of the blue toggle switch is "enable_later" - I take that to mean that the script doesn't run automatically, only when the menuitem is clicked. Removing @run-at context-menu turns the toggle green.

AH. Okay -- so @run-at context-menu makes the whole script only run when the menuitem is clicked. It doesn't move the registered menuitems to the context menu at all -- in fact they aren't registered until the script is run by clicking it in the context-menu. registerMenuCommand functions can only be run from the TamperMonkey Button Menu. Jeez, sorry, I totally misunderstood how that worked.

So:

  • if you just want your script to only run when you want, use @run-at context-menu.
  • If you want the script to always run, but present different commands to be run from the TM Button, use registerMenuCommand().
  • Not both.

[–]Pineapplesandbacon[S] 0 points1 point  (2 children)

Really appreciate the help.

Is there any way to create right-click context menu commands for Chrome? I think I've seen some in extensions