Files
I2P_in_Private_Browsing_Mod…/proxy.js

68 lines
2.0 KiB
JavaScript
Raw Normal View History

2019-02-05 17:27:39 -05:00
function isFirefox() {
testPlain = navigator.userAgent.indexOf('Firefox') !== -1;
if (testPlain) {
2019-05-02 17:31:04 -04:00
console.log("firefox")
2019-02-05 17:27:39 -05:00
return testPlain
}
return false
}
2019-05-02 17:31:04 -04:00
function isDroid() {
2019-05-02 17:31:04 -04:00
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then((got) => {
if (got.os == "android") {
return true
}
});
}
2019-03-15 21:45:59 -04:00
if (isFirefox()) {
browser.privacy.network.peerConnectionEnabled.set({value: false});
}
chrome.privacy.network.networkPredictionEnabled.set({value: false});
chrome.privacy.network.webRTCIPHandlingPolicy.set({value: "disable_non_proxied_udp"});
console.log("Preliminarily disabled WebRTC.")
function shouldProxyRequest(requestInfo) {
return true; //requestInfo.parentFrameId != -1;
}
function setupProxy() {
2019-05-02 17:31:04 -04:00
var controlHost = "127.0.0.1" //getControlHost()
var controlPort = "7951" //getControlPort();
var Host = "127.0.0.1" //getHost()
var Port = "4444" //getPort()
2019-05-02 17:31:04 -04:00
if (isDroid()) {
console.log("Setting up Firefox Android proxy")
function handleProxyRequest(requestInfo) {
if (shouldProxyRequest(requestInfo)) {
console.log(`Proxying: ${requestInfo.url}`);
return {type: "http", host: Host, port: Port};
}
return {type: "http", host: Host, port: Port};
}
browser.proxy.onRequest.addListener(handleProxyRequest, {urls: ["<all_urls>"]});
2019-05-02 17:31:04 -04:00
console.log("i2p settings created for Firefox Android")
}else{
console.log("Setting up Firefox Desktop proxy")
var proxySettings = {
proxyType: "manual",
http: Host+":"+Port,
passthrough: "",
httpProxyAll: true
};
browser.proxy.settings.set({value:proxySettings});
console.log("i2p settings created for Firefox Desktop")
}
2019-02-05 17:27:39 -05:00
}
2019-02-21 22:51:59 -05:00
2019-03-15 21:45:59 -04:00
if (isFirefox()){
// Theme all currently open windows
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
}
2019-05-02 17:31:04 -04:00
if (isFirefox()) {
setupProxy()
}