3

I have several different GM scripts executing on the same page (running via Tampermonkey, although similar behavior observed using Greasemonkey). The other scripts are utilizing GM API calls and are specified in their scripts using @grant (GM_xmlhttpRequest, GM_addStyle, GM_*Value calls). A new script I'm working on doesn't need access to any of these, and so I left the Tampermonkey new script default value of @grant none.

Leaving @grant none breaks the other scripts as well as some javascript/jquery content running on the page. Specifying no @grant at all allows everything to function as expected.

According to https://wiki.greasespot.net/@grant, when no @grant is specified, none is implied. Tampermonkey looks like it guesses what the script needs, so no idea what it's doing behind the scenes for this specific script (https://tampermonkey.net/documentation.php#_grant).

Any ideas as to the source of this wonkiness, or is it only wonky to me because I'm missing something here?

If example code is necessary, this is the gist of what I'm doing. It's really not complicated at all (reduced to just an example since this is internal code I'm working on):

var found = false;
$.each($('#id').children(),function(i,value){
    if ($(value).text == 'my string'){
        found = true;
    }
});
if (found){
    $('#id').append('<div></div>');
}

EDIT: If this is a bug, hopefully some traction here: https://forum.tampermonkey.net/viewtopic.php?f=17&t=2384

  • so, are you using GreaseMonkey or TamperMonkey addon? ... the code you posted requires nothing to be "granted" anyway - though, ugh, jquery in a userscript? that's like putting a Toyota engine into a Ferrari – Jaromanda X Dec 28 '17 at 01:05
  • As specified in the post, both Greasemonkey and Tampermonkey are being used (multiple people consuming the script) and the same behavior is being exhibited. – Pickle Rick Dec 28 '17 at 01:11
  • Sorry, wasn't clear (I should've just re-read the post :p ) – Jaromanda X Dec 28 '17 at 01:15
  • Are you saying putting `@grant none` in one script breaks other scripts (when using TamperMonkey)? That would seem to be a bug in TamperMonkey – Jaromanda X Dec 28 '17 at 01:18
  • 1
    Yes, `@grant none` in the new script not only breaks other scripts but is also preventing some on page javascript from running. Leaving it out breaks nothing. – Pickle Rick Dec 28 '17 at 01:19
  • That really does seem to be a TamperMonkey bug in that case! – Jaromanda X Dec 28 '17 at 01:25

0 Answers0