Firefox addon 插件如何侦听Firefox从HTML页面请求的HTTP头?
我需要通过代理发送FirefoxFirefox addon 插件如何侦听Firefox从HTML页面请求的HTTP头?,firefox-addon,firefox-addon-sdk,Firefox Addon,Firefox Addon Sdk,我需要通过代理发送Firefoxhtml-页面请求,以及页面上的所有其他内容-图片、样式、视频、音乐、flash等,无需代理即可请求。 我创建:函数代理(类型、http、端口、无代理): var prefsvc = require("sdk/preferences/service"); function proxy(type,http,port,no_proxies) { prefsvc.set("network.proxy.type", type); prefsvc.set("
html
-页面请求,以及页面上的所有其他内容-图片、样式、视频、音乐、flash等,无需代理即可请求。我创建:
代理(类型、http、端口、无代理)
:var prefsvc = require("sdk/preferences/service");
function proxy(type,http,port,no_proxies) {
prefsvc.set("network.proxy.type", type);
prefsvc.set("network.proxy.http", http);
prefsvc.set("network.proxy.http_port", port);
prefsvc.set("network.proxy.no_proxies_on", no_proxies);}
var-button=require('sdk/ui/button/action').ActionButton({id:“代理按钮”,标签:“代理按钮”,图标:{“16”:“/icon-16.png”},onClick:handleClick})代码>
handleClick(state)
,它:var tabs = require("sdk/tabs");
var Request = require("sdk/request").Request;
function handleClick(state) {
打开一个新选项卡:选项卡。打开(“https://developer.mozilla.org/");代码>
通过此选项卡内容类型-标题的URL从目标服务器请求,如果它与html
-页面的标题(text/html
)一致,则更改Firefox的代理,如果请求不是html
-页面,则禁用代理:
Request({url: tabs.activeTab.url, onComplete: function (response) {
'text/html'==response.headers['Content-Type'].split(';',1)
? proxy(1,"192.168.56.101",8880,"localhost, 127.0.0.1, 192.168.1.1")
: proxy(5,'','','');
}}).head();}
我如何收听来自页面链接的所有http请求?
谢谢