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
|
|
|
|
2019-03-16 11:28:20 -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-16 11:28:20 -04:00
|
|
|
}
|
|
|
|
|
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"});
|
2019-02-05 17:38:38 -05:00
|
|
|
|
2019-02-05 21:50:25 -05:00
|
|
|
console.log("Preliminarily disabled WebRTC.")
|
|
|
|
|
2019-05-03 18:40:46 -04:00
|
|
|
function shouldProxyRequest(requestInfo) {
|
|
|
|
return true; //requestInfo.parentFrameId != -1;
|
|
|
|
}
|
|
|
|
|
2019-02-07 17:25:06 -05:00
|
|
|
function setupProxy() {
|
2019-05-02 17:31:04 -04:00
|
|
|
var controlHost = "127.0.0.1" //getControlHost()
|
|
|
|
var controlPort = "7951" //getControlPort();
|
2019-05-03 18:40:46 -04:00
|
|
|
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")
|
2019-05-03 18:40:46 -04:00
|
|
|
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};
|
2019-02-07 17:25:06 -05:00
|
|
|
}
|
2019-05-03 18:40:46 -04:00
|
|
|
browser.proxy.onRequest.addListener(handleProxyRequest, {urls: ["<all_urls>"]});
|
2019-05-02 17:31:04 -04:00
|
|
|
console.log("i2p settings created for Firefox Android")
|
2019-05-03 18:40:46 -04:00
|
|
|
}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-07 17:09:31 -05:00
|
|
|
}
|
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()
|
|
|
|
}
|