When my GM script does this:
var curTab = GM_openInTab(url);
it results in a \'GM_openInTab is not defined\'
JavaScript error
In order to use any of the GM_
functions, you must set a matching @grant directiveDoc (As of Greasemonkey version 2.0Release notes)
For example:
// ==UserScript==
// @name _YOUR_SCRIPT_NAME
// @include http://YOUR_SERVER.COM/YOUR_PATH/*
// @grant GM_openInTab
// ==/UserScript==
var curTab = GM_openInTab ("http://pwnthemall.com/");
Note that this has the side effect of switching Greasemonkey's sandbox back on. See also:
Tampermonkey emulates most of this behavior as of version 3.9Release notes. But the current version (3.9.202) still attempts to guess appropriate values if @grant
is not specified, so you won't necessarily see an error (yet).
Always use @grant
anyway, for maximum compatibility and to future-proof your code.