use*_*375 13 firefox greasemonkey userscripts
我的用户脚本使用打印一些信息console.log().
这在Chrome中运行良好,但是当我在Firefox(Greasemonkey)中安装此用户脚本时,Firefox中的Web控制台无法显示任何内容.
我搜索了一个解决方案,有些人建议使用,unsafeWindow但它也没有显示任何输出.而且unsafeWindow不能用于镀铬.我甚至安装了Firebug,但没用.我该如何解决这个问题?
例如,我在Firefox中试过这个用户脚本:
// ==UserScript==
// @name console
// ==UserScript==
console.log("hello");
Run Code Online (Sandbox Code Playgroud)
Bro*_*ams 16
你的意思是当它通过Greasemonkey安装时不起作用,对吗?
不久前,Greasemonkey破解了console.log(New!Bug报告).现在,要查看console.log()Greasemonkey 的普通调用结果,您需要查看Firefox的错误控制台,而不是Firebug.
按:可以看到FF的错误控制台CtrlShiftJ.
但是,您可以unsafeWindow.console.log()在Chrome和Greasemonkey脚本中使用.Chrome现在支持有限unsafeWindow.
如果您使用unsafeWindow,您可以从Greasemonkey 访问所有Firebug的日志记录功能.(必须安装Firebug并且它们仍然可能无法在Chrome用户脚本中使用;我有一段时间没有测试过.)
在Firefox中,如果未安装Firebug,或者页面未激活,则unsafeWindow.console.log()调用将显示在新的"Web控制台"(CtrlShiftK)中.
您需要unsafeWindow在Greasemonkey脚本中使用when.
需要注意的是火狐目前支持console.log(),console.info(),console.warn(),和console.error()原生-无需萤火虫.
等一下:如果问题是关于使用Greasemonkey登录控制台(我可以发誓我看到标签greasemonkey),为什么不使用该GM_log方法?
// ==UserScript==
// @name GM_log Example
// @namespace http://www.example.com/
// ==/UserScript==
GM_log("This is an example of GM_log");
Run Code Online (Sandbox Code Playgroud)
或者我错过了什么?
PS:你也可以查看javascript.options.showInConsoleabout:config.它应该是true.
| 归档时间: |
|
| 查看次数: |
21957 次 |
| 最近记录: |