有没有办法从 Firefox 的 cfx 使用 Firebug 的 console.log?
使用附加 SDK 的 cfx run 命令,是否可以让它登录 Firebug 控制台,而不是从主附加代码或内容脚本登录命令行?
Using the Add-on SDK's cfx run
command, is it possible to get it to log to Firebug's console instead of the command line one from the main add-on code or content scripts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用未记录的属性
unsafeWindow
。顾名思义,这是一个坏主意。但是,由于您仅使用它来调试,所以一切都应该没问题。请在发布您的插件时删除这些声明。如果您想让所有控制台调用转到 firebug,您可以将以下内容放入内容脚本中。
如果您只想记录
注意: 当我在
contentScriptWhen: "start"
page-mod 上运行它时,我注意到 Firebug 尚未加载到控制台对象中。因此,如果您使用contentScriptWhen: "start"
,则在访问控制台之前可能需要稍微延迟。You can use the undocumented property
unsafeWindow
. As its name implies, this is a BAD IDEA. But, as you are only using it for debugging everything should be fine. Please remove these statements when releasing your addon.If you want to make all console calls go to firebug you can put the following in your content script.
If you just want log
Note: When I was running this on a
contentScriptWhen: "start"
page-mod I noticed that Firebug hadn't loaded into the console object yet. So if you are usingcontentScriptWhen: "start"
you may need a slight delay before accessing the console.