如何在 Firefox 扩展中设置 HTTP 标头?
我将做到这一点,以便这些仅在访问我的网站时发送,以便我可以检测插件是否已安装,如果安装了,则不会推广该插件。
这是我发现的最紧凑的方法:
Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService ).addObserver({
observe : function(subject, topic, data) {
var channel = subject.QueryInterface( Components.interfaces.nsIHttpChannel );
if ( /mysite/.test( channel.originalURI.host ) ) {
channel.setRequestHeader("x-mysite-extended", "true", false);
}
}
},"http-on-modify-request",false);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)