GM_openInTab (or any other GM_ function) is not defined?

坚强是说给别人听的谎言 提交于 2019-12-01 21:30:29
Brock Adams

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!