无法让 ff 扩展在 v3.0.5 中工作
有谁知道自 v3.0.5 以来可能发生哪些变化才能使扩展正常工作?或者,也许我在某个地方缺少设置?我编写的这个附加组件可以在较新的版本中正常工作,但我无法让它在较旧的版本中启动。具体来说,我什至无法让这部分工作(这是在我的浏览器overlay.xul中):
<html:script>
<![CDATA[
var Cc = Components.classes;
var Ci = Components.interfaces;
var obSvc = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
gBrowser.consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
gBrowser.log = function(msg){
this.consoleService.logStringMessage(msg);
}
gBrowser.newObj= new MyAddOn();
gBrowser.log("initializing...");
function regListener()
{
obSvc.addObserver(gBrowser.newObj, "http-on-modify-request", false);
}
function unregListener()
{
obSvc.removeObserver(gBrowser.newObj, "http-on-modify-request");
}
window.addEventListener("load", regListener, false);
window.addEventListener("unload", unregListener, false);
]]>
这个应该将侦听器附加到新的obj(由链接的.js定义)但是,我什至没有在控制台中收到“正在初始化...”消息。有什么想法吗?
Does anyone know what might have changed since v3.0.5 that would enable extensions to work? Or, maybe I'm missing a setting somewhere? I wrote this add-on that works fine with newer versions, but I can't get it to launch in older ones. Specifically, I can't even get this part to work (this is in my browser overlay.xul):
<html:script>
<![CDATA[
var Cc = Components.classes;
var Ci = Components.interfaces;
var obSvc = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
gBrowser.consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
gBrowser.log = function(msg){
this.consoleService.logStringMessage(msg);
}
gBrowser.newObj= new MyAddOn();
gBrowser.log("initializing...");
function regListener()
{
obSvc.addObserver(gBrowser.newObj, "http-on-modify-request", false);
}
function unregListener()
{
obSvc.removeObserver(gBrowser.newObj, "http-on-modify-request");
}
window.addEventListener("load", regListener, false);
window.addEventListener("unload", unregListener, false);
]]>
This should attach listeners to the new obj (defined by a linked .js) However, I'm not even getting the "initializing..." message in the console. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
var Cc
))。如果每个人都这样做,那么两个扩展就不会一起工作。将所有代码属性放在您自己的对象上并使用唯一的名称。gBrowser
可能是导致您出现特定问题的原因。var Cc
)) with your own properties. If everyone did that, no two extensions would work together. Put all your code properties on your own object with a unique name.gBrowser
before the load event is probably what's causing your specific problem.看起来 gBrowser.log 未定义,或者至少不是函数,错误控制台可能会告诉您。我也从未听说过。也许它是在 Fx 3.5 中添加的?
It looks like
gBrowser.log
is not defined, or at least is not a function, as the error console will probably tell you. I've never heard of it either. Maybe it was added in Fx 3.5?