Files
webextensions-examples/proxy-blocker/proxy/proxy-script.js
Phil Rukin 980168290f Update proxy-blocker extension to be compatible with firefox 56+ (#260)
* Update `proxy-blocker` extension to be compatible with firefox 56+

* Change `DIRECT 1234` to `DIRECT` see bug https://bugzilla.mozilla.org/show_bug.cgi?id=1355198
2017-08-11 05:48:55 -07:00

24 lines
608 B
JavaScript

/* exported FindProxyForURL */
var blockedHosts = [];
const allow = "DIRECT";
const deny = "PROXY 127.0.0.1:65535";
// tell the background script that we are ready
browser.runtime.sendMessage("init");
// listen for updates to the blocked host list
browser.runtime.onMessage.addListener((message) => {
blockedHosts = message;
});
// required PAC function that will be called to determine
// if a proxy should be used.
function FindProxyForURL(url, host) {
if (blockedHosts.indexOf(host) != -1) {
browser.runtime.sendMessage(`Proxy-blocker: blocked ${url}`);
return deny;
}
return allow;
}