@run-at context-menu

Post Reply
abeall
Posts: 4
Joined: 06.03.17 20:27:57

@run-at context-menu

Post by abeall » 06.03.17 20:35:21

I'm trying to write a script that is available to all websites, but only runs if I select it from the menu. I thought this is what

Code: Select all

// @run-at context-menu
would do, but I'm seeing weird behavior. My meta block looks like this:

Code: Select all

// ==UserScript==
// @name         Indexer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @indluce      *
// @run-at       context-menu
// @grant        none
// ==/UserScript==
But when I click the menu button in Chrome I see a weird buggy flash sometimes and the script listed twice (if on) or once (if off) and it never gets injected in either case.

How can I make this work?

wOxxOm
Posts: 6
Joined: 15.09.14 14:11:59

Re: @run-at context-menu

Post by wOxxOm » 02.04.17 08:17:53

Code: Select all

@indluce
- a typo?

This works for me:

Code: Select all

// ==UserScript==
// @name         Indexer
// @run-at       context-menu
// ==/UserScript==
alert('yo!');

abeall
Posts: 4
Joined: 06.03.17 20:27:57

Re: @run-at context-menu

Post by abeall » 31.05.17 16:23:30

Ah yes that was a typo, I tried a lot of different combinations but that's been fixed.

For me your example doesn't work. I copied your code into a new script and named it Yo, then I went to a website and saw Yo in the context menu and off (as expected) but when I toggle it on, it just disappears and the "yo!" alert is never shown. Refreshing doesn't bring it back in the context menu either. I have to turn it off and on in the dashboard, which doesn't make it work but brings it back in the context menu.

Image

User avatar
derjanb
Site Admin
Posts: 2383
Joined: 20.01.06 02:16:15
Contact:

Re: @run-at context-menu

Post by derjanb » 31.05.17 19:37:00

Just enable the script (again), reload and open the context menu of the page (right mouse click).
ImageIf you like what I'm doing, please consider a donation here. Image

abeall
Posts: 4
Joined: 06.03.17 20:27:57

Re: @run-at context-menu

Post by abeall » 31.05.17 20:04:19

Thanks but I think I don't understand how this is supposed to work... when I enable it via the context menu it does not run the script. I was hoping that it would run the script if I turn it on without needing to reload the page. Is that not how it's supposed to work?

abeall
Posts: 4
Joined: 06.03.17 20:27:57

Re: @run-at context-menu

Post by abeall » 31.05.17 20:10:34

AH now I get it, I read your last reply too quickly. I just need to use the actual mouse right-click context menu. For some reason I thought "context-menu" referred to the main tampermonkey menu in the toolbar. I also had to remove "@include: *" otherwise it would show up twice in the tampermonkey menu and do those weird things.

User avatar
derjanb
Site Admin
Posts: 2383
Joined: 20.01.06 02:16:15
Contact:

Re: @run-at context-menu

Post by derjanb » 31.05.17 20:12:20

Great! :D

And of course, I need to fix the @include issue...
ImageIf you like what I'm doing, please consider a donation here. Image

Post Reply