GM_log和其他GM功能在Greasemonkey脚本中不起作用 [英] GM_log and other GM functions don't work in Greasemonkey scripts
问题描述
我在Firefox中创建了一个"Hello World" Greasemonkey脚本,该脚本只包含一行代码:
GM_log("Hello World");
这似乎没有作用,至少在我的Firebug控制台中没有产生任何输出.
与其他GM _...函数一样,例如GM_wait
当我更换时:
GM_log("Hello World");
具有:
alert("Hello World")
它起作用了(所以脚本标题不是问题).
我还将以下about:config
选项设置为true:
-
javascript.options.showInConsole
-
extensions.firebug.showChromeErrors
-
extensions.firebug.showChromeMessages
是否需要更改其他设置以使GM _...函数在Greasemonkey脚本中工作?
我是否必须更改其他GM_log消息的Firebug设置才能在Firebug控制台中显示?
原因是在GM 1.0中添加了新的特殊元数据块命令: @grant .
如果需要GM_log起作用,则必须将此行添加到脚本元数据块中:
"// @grant GM_log"
,否则它将无法正常工作.
您可以在 http://wiki.greasespot.net/@grant 中了解此功能.. >
I have created a "Hello World" Greasemonkey script in Firefox which contains only one line of code:
GM_log("Hello World");
This did not seem to function, at least it did not produce any output in my firebug console.
The same with other GM_... functions like GM_wait
When I replaced:
GM_log("Hello World");
with:
alert("Hello World")
it worked (so the script headers are not the problem).
I have also set the following about:config
options to true:
javascript.options.showInConsole
extensions.firebug.showChromeErrors
extensions.firebug.showChromeMessages
Is there some other setting to change for GM_... functions to work in Greasemonkey scripts?
Do I have to change other firebug settings for GM_log messages to show in the firebug console?
The reason for this is a new special Metadata Block imperative: @grant, added in GM 1.0.
If you need GM_log to work, you have to add this line into your script Metadata Block:
"// @grant GM_log"
, otherwise it will not work.
You can read about this feature at http://wiki.greasespot.net/@grant.
这篇关于GM_log和其他GM功能在Greasemonkey脚本中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!