improve fomatting, add better socks defaults and enforce them
This commit is contained in:
108
background.js
108
background.js
@@ -10,77 +10,77 @@ function getChrome() {
|
||||
}
|
||||
|
||||
function isDroid() {
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
console.log("android detected")
|
||||
return true
|
||||
}else{
|
||||
console.log("desktop detected")
|
||||
return false
|
||||
}
|
||||
});
|
||||
}
|
||||
return false
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
console.log("android detected")
|
||||
return true
|
||||
} else {
|
||||
console.log("desktop detected")
|
||||
return false
|
||||
}
|
||||
});
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if (!isDroid()) {
|
||||
chrome.windows.onCreated.addListener(themeWindow);
|
||||
chrome.windows.onCreated.addListener(themeWindow);
|
||||
}
|
||||
|
||||
var titlepref = chrome.i18n.getMessage("titlePreface");
|
||||
var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate");
|
||||
|
||||
function themeWindow(window) {
|
||||
// Check if the window is in private browsing
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#2D4470",
|
||||
toolbar: "#2D4470",
|
||||
}
|
||||
});
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
}
|
||||
else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#9DABD5",
|
||||
toolbar: "#9DABD5",
|
||||
}
|
||||
});
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
// Check if the window is in private browsing
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#2D4470",
|
||||
toolbar: "#2D4470",
|
||||
}
|
||||
});
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#9DABD5",
|
||||
toolbar: "#9DABD5",
|
||||
}
|
||||
});
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setTitle(window){
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
}
|
||||
else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
function setTitle(window) {
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setTitleError(window){
|
||||
alert("plugin error setting title on", window.id)
|
||||
function setTitleError(window) {
|
||||
alert("plugin error setting title on", window.id)
|
||||
}
|
||||
|
||||
chrome.windows.onCreated.addListener(() => {
|
||||
const gettingStoredSettings = chrome.storage.local.get();
|
||||
gettingStoredSettings.then(setupProxy, onError);
|
||||
const gettingStoredSettings = chrome.storage.local.get();
|
||||
gettingStoredSettings.then(setupProxy, onError);
|
||||
});
|
||||
|
||||
chrome.tabs.onCreated.addListener(() => {
|
||||
const getting = browser.windows.getCurrent({populate: true});
|
||||
getting.then(setTitle, setTitleError);
|
||||
const getting = browser.windows.getCurrent({
|
||||
populate: true
|
||||
});
|
||||
getting.then(setTitle, setTitleError);
|
||||
});
|
||||
|
22
info.js
22
info.js
@@ -22,15 +22,15 @@ document.addEventListener("click", (e) => {
|
||||
console.log("The news panel has been created");
|
||||
});
|
||||
} else if (e.target.id === "generate-fresh-tunnel") {
|
||||
function RefreshIdentity(){
|
||||
console.log("Generating new identity")
|
||||
const Http = new XMLHttpRequest();
|
||||
const url='http://' + controlHost + ":" + controlPort
|
||||
Http.open("GET", url);
|
||||
Http.send();
|
||||
Http.onreadystatechange=(e)=>{
|
||||
console.log(Http.responseText)
|
||||
}
|
||||
function RefreshIdentity() {
|
||||
console.log("Generating new identity")
|
||||
const Http = new XMLHttpRequest();
|
||||
const url = 'http://' + controlHost + ":" + controlPort
|
||||
Http.open("GET", url);
|
||||
Http.send();
|
||||
Http.onreadystatechange = (e) => {
|
||||
console.log(Http.responseText)
|
||||
}
|
||||
}
|
||||
RefreshIdentity();
|
||||
} else if (e.target.id === "window-preface-title") {
|
||||
@@ -40,8 +40,8 @@ document.addEventListener("click", (e) => {
|
||||
}
|
||||
chrome.windows.update(currentWindow.id, updateInfo);
|
||||
});
|
||||
}else if (e.target.id === "clear-browser-data") {
|
||||
forgetBrowsingData()
|
||||
} else if (e.target.id === "clear-browser-data") {
|
||||
forgetBrowsingData()
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
@@ -1,185 +1,192 @@
|
||||
|
||||
function isDroid() {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
return true
|
||||
}else{
|
||||
return false
|
||||
}
|
||||
});
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function SetHostText(){
|
||||
var hostid = document.getElementById('hostText');
|
||||
hostid.textContent = chrome.i18n.getMessage("hostText");
|
||||
function SetHostText() {
|
||||
var hostid = document.getElementById('hostText');
|
||||
hostid.textContent = chrome.i18n.getMessage("hostText");
|
||||
}
|
||||
|
||||
function SetPortText(){
|
||||
var portid = document.getElementById('portText');
|
||||
portid.textContent = chrome.i18n.getMessage("portText");
|
||||
function SetPortText() {
|
||||
var portid = document.getElementById('portText');
|
||||
portid.textContent = chrome.i18n.getMessage("portText");
|
||||
}
|
||||
|
||||
function SetControlHostText(){
|
||||
var controlhostid = document.getElementById('controlHostText');
|
||||
controlhostid.textContent = chrome.i18n.getMessage("controlHostText");
|
||||
function SetControlHostText() {
|
||||
var controlhostid = document.getElementById('controlHostText');
|
||||
controlhostid.textContent = chrome.i18n.getMessage("controlHostText");
|
||||
}
|
||||
|
||||
function setupProxy() {
|
||||
var controlHost = getControlHost()
|
||||
var controlPort = getControlPort();
|
||||
var Host = getHost()
|
||||
var Port = getPort()
|
||||
var Scheme = getScheme()
|
||||
function handleProxyRequest(requestInfo) {
|
||||
console.log("proxying request via listener")
|
||||
console.log(" ", Scheme, Host, ":", Port,)
|
||||
return {type: Scheme, host: Host, port: Port, proxyDns: true}
|
||||
var controlHost = getControlHost()
|
||||
var controlPort = getControlPort();
|
||||
var Host = getHost()
|
||||
var Port = getPort()
|
||||
var Scheme = getScheme()
|
||||
function handleProxyRequest(requestInfo) {
|
||||
console.log("proxying request via listener")
|
||||
console.log(" ", Scheme, Host, ":", Port,)
|
||||
return {
|
||||
type: Scheme,
|
||||
host: Host,
|
||||
port: Port,
|
||||
proxyDns: true
|
||||
}
|
||||
console.log("Setting up Firefox WebExtension proxy")
|
||||
browser.proxy.onRequest.addListener(handleProxyRequest, {urls: ["<all_urls>"]});
|
||||
console.log("i2p settings created for WebExtension Proxy")
|
||||
}
|
||||
console.log("Setting up Firefox WebExtension proxy")
|
||||
browser.proxy.onRequest.addListener(handleProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy")
|
||||
}
|
||||
|
||||
function SetControlPortText(){
|
||||
var controlportid = document.getElementById('controlPortText');
|
||||
controlportid.textContent = chrome.i18n.getMessage("controlPortText");
|
||||
function SetControlPortText() {
|
||||
var controlportid = document.getElementById('controlPortText');
|
||||
controlportid.textContent = chrome.i18n.getMessage("controlPortText");
|
||||
}
|
||||
|
||||
function SetControlHelpText(){
|
||||
var portid = document.getElementById('controlHelpText');
|
||||
portid.textContent = chrome.i18n.getMessage("controlHelpText");
|
||||
function SetControlHelpText() {
|
||||
var portid = document.getElementById('controlHelpText');
|
||||
portid.textContent = chrome.i18n.getMessage("controlHelpText");
|
||||
}
|
||||
|
||||
function getScheme() {
|
||||
const proxy_scheme = document.querySelector("#proxy_scheme");
|
||||
console.log("Got i2p proxy scheme:", proxy_scheme.value);
|
||||
if (proxy_scheme == "HTTP") {
|
||||
return "http"
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
return "socks"
|
||||
}
|
||||
return proxy_scheme.value;
|
||||
const proxy_scheme = document.querySelector("#proxy_scheme");
|
||||
console.log("Got i2p proxy scheme:", proxy_scheme.value);
|
||||
if (proxy_scheme == "HTTP") {
|
||||
return "http"
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
return "socks"
|
||||
}
|
||||
return proxy_scheme.value;
|
||||
}
|
||||
|
||||
function getHost() {
|
||||
proxy_host = document.getElementById("host").value
|
||||
console.log("Got i2p proxy host:", proxy_host);
|
||||
if (proxy_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
return proxy_host;
|
||||
proxy_host = document.getElementById("host").value
|
||||
console.log("Got i2p proxy host:", proxy_host);
|
||||
if (proxy_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
return proxy_host;
|
||||
}
|
||||
|
||||
function getPort() {
|
||||
proxy_port = document.getElementById("port").value
|
||||
console.log("Got i2p proxy port:", proxy_port);
|
||||
if (proxy_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
return proxy_port;
|
||||
proxy_port = document.getElementById("port").value
|
||||
console.log("Got i2p proxy port:", proxy_port);
|
||||
if (proxy_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
return proxy_port;
|
||||
}
|
||||
|
||||
function getControlHost() {
|
||||
control_host = document.getElementById("controlhost").value
|
||||
console.log("Got i2p control host:", control_host);
|
||||
if (control_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
return control_host;
|
||||
control_host = document.getElementById("controlhost").value
|
||||
console.log("Got i2p control host:", control_host);
|
||||
if (control_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
return control_host;
|
||||
}
|
||||
|
||||
function getControlPort() {
|
||||
control_port = document.getElementById("controlport").value
|
||||
console.log("Got i2p control port:", control_port);
|
||||
if (control_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
return control_port;
|
||||
control_port = document.getElementById("controlport").value
|
||||
console.log("Got i2p control port:", control_port);
|
||||
if (control_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
return control_port;
|
||||
}
|
||||
|
||||
function checkStoredSettings(storedSettings) {
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme){
|
||||
defaultSettings["proxy_scheme"] = "http"
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http"
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
function storeSettings() {
|
||||
let proxy_scheme = getScheme()
|
||||
let proxy_host = getHost()
|
||||
let proxy_port = getPort()
|
||||
let control_host = getControlHost()
|
||||
let control_port = getControlPort()
|
||||
chrome.storage.local.set({
|
||||
proxy_scheme,
|
||||
proxy_host,
|
||||
proxy_port,
|
||||
control_host,
|
||||
control_port,
|
||||
});
|
||||
console.log("storing proxy scheme:", proxy_scheme)
|
||||
console.log("storing proxy host:", proxy_host)
|
||||
console.log("storing proxy port:", proxy_port)
|
||||
console.log("storing control host:", control_host)
|
||||
console.log("storing control port:", control_port)
|
||||
setupProxy()
|
||||
let proxy_scheme = getScheme()
|
||||
let proxy_host = getHost()
|
||||
let proxy_port = getPort()
|
||||
let control_host = getControlHost()
|
||||
let control_port = getControlPort()
|
||||
chrome.storage.local.set({
|
||||
proxy_scheme,
|
||||
proxy_host,
|
||||
proxy_port,
|
||||
control_host,
|
||||
control_port,
|
||||
});
|
||||
console.log("storing proxy scheme:", proxy_scheme)
|
||||
console.log("storing proxy host:", proxy_host)
|
||||
console.log("storing proxy port:", proxy_port)
|
||||
console.log("storing control host:", control_host)
|
||||
console.log("storing control port:", control_port)
|
||||
setupProxy()
|
||||
}
|
||||
|
||||
function updateUI(restoredSettings) {
|
||||
|
||||
const selectList = document.querySelector("#proxy_scheme")
|
||||
selectList.value = restoredSettings.proxy_scheme
|
||||
console.log("showing proxy scheme:", selectList.value)
|
||||
const selectList = document.querySelector("#proxy_scheme")
|
||||
selectList.value = restoredSettings.proxy_scheme
|
||||
console.log("showing proxy scheme:", selectList.value)
|
||||
|
||||
const hostitem = document.getElementById("host")
|
||||
hostitem.value = restoredSettings.proxy_host
|
||||
console.log("showing proxy host:", hostitem.value)
|
||||
const hostitem = document.getElementById("host")
|
||||
hostitem.value = restoredSettings.proxy_host
|
||||
console.log("showing proxy host:", hostitem.value)
|
||||
|
||||
const portitem = document.getElementById("port")
|
||||
portitem.value = restoredSettings.proxy_port
|
||||
console.log("showing proxy port:", portitem.value)
|
||||
const portitem = document.getElementById("port")
|
||||
portitem.value = restoredSettings.proxy_port
|
||||
console.log("showing proxy port:", portitem.value)
|
||||
|
||||
const controlhostitem = document.getElementById("controlhost")
|
||||
controlhostitem.value = restoredSettings.control_host
|
||||
console.log("showing control host:", controlhostitem.value)
|
||||
const controlhostitem = document.getElementById("controlhost")
|
||||
controlhostitem.value = restoredSettings.control_host
|
||||
console.log("showing control host:", controlhostitem.value)
|
||||
|
||||
const controlportitem = document.getElementById("controlport")
|
||||
controlportitem.value = restoredSettings.control_port
|
||||
console.log("showing control port:", controlportitem.value)
|
||||
const controlportitem = document.getElementById("controlport")
|
||||
controlportitem.value = restoredSettings.control_port
|
||||
console.log("showing control port:", controlportitem.value)
|
||||
|
||||
SetHostText()
|
||||
SetPortText()
|
||||
SetControlHostText()
|
||||
SetControlPortText()
|
||||
SetControlHelpText()
|
||||
setupProxy()
|
||||
SetHostText()
|
||||
SetPortText()
|
||||
SetControlHostText()
|
||||
SetControlPortText()
|
||||
SetControlHelpText()
|
||||
setupProxy()
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
console.error(e);
|
||||
}
|
||||
chrome.storage.local.get(function(got){
|
||||
checkStoredSettings(got)
|
||||
updateUI(got)
|
||||
chrome.storage.local.get(function(got) {
|
||||
checkStoredSettings(got)
|
||||
updateUI(got)
|
||||
});
|
||||
|
||||
const saveButton = document.querySelector("#save-button");
|
||||
|
223
proxy.js
223
proxy.js
@@ -10,27 +10,33 @@ function getChrome() {
|
||||
}
|
||||
|
||||
function isDroid() {
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
console.log("android detected")
|
||||
return true
|
||||
}else{
|
||||
console.log("desktop detected")
|
||||
return false
|
||||
}
|
||||
});
|
||||
}
|
||||
return false
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
console.log("android detected")
|
||||
return true
|
||||
} else {
|
||||
console.log("desktop detected")
|
||||
return false
|
||||
}
|
||||
});
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({value: false});
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
|
||||
chrome.privacy.network.networkPredictionEnabled.set({value: false});
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({value: "disable_non_proxied_udp"});
|
||||
chrome.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
});
|
||||
|
||||
console.log("Preliminarily disabled WebRTC.")
|
||||
|
||||
@@ -39,133 +45,144 @@ function shouldProxyRequest(requestInfo) {
|
||||
}
|
||||
|
||||
function handleProxyRequest(requestInfo) {
|
||||
console.log(`Proxying: ${requestInfo.url}`);
|
||||
console.log(" ", getScheme(), getHost(), ":", getPort(),)
|
||||
return {type: getScheme(), host: getHost(), port: getPort()};
|
||||
console.log(`Proxying: ${requestInfo.url}`);
|
||||
console.log(" ", getScheme(), getHost(), ":", getPort(),)
|
||||
return {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
}
|
||||
|
||||
var proxy_scheme = "HTTP"
|
||||
|
||||
function getScheme() {
|
||||
if (proxy_scheme == undefined) {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
if (proxy_scheme == "HTTP") {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
proxy_scheme = "socks"
|
||||
}
|
||||
if ( proxy_scheme != "http" && proxy_scheme != "socks" ){
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
console.log("Got i2p proxy scheme:", proxy_scheme);
|
||||
return proxy_scheme;
|
||||
if (proxy_scheme == undefined) {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
if (proxy_scheme == "HTTP") {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
proxy_scheme = "socks"
|
||||
}
|
||||
if (proxy_scheme != "http" && proxy_scheme != "socks") {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
console.log("Got i2p proxy scheme:", proxy_scheme);
|
||||
return proxy_scheme;
|
||||
}
|
||||
|
||||
var proxy_host = "127.0.0.1"
|
||||
|
||||
function getHost() {
|
||||
if (proxy_host == undefined){
|
||||
proxy_host = "127.0.0.1"
|
||||
}
|
||||
console.log("Got i2p proxy host:", proxy_host);
|
||||
return proxy_host;
|
||||
if (proxy_host == undefined) {
|
||||
proxy_host = "127.0.0.1"
|
||||
}
|
||||
console.log("Got i2p proxy host:", proxy_host);
|
||||
return proxy_host;
|
||||
}
|
||||
|
||||
var proxy_port = "4444"
|
||||
|
||||
function getPort() {
|
||||
if (proxy_port == undefined){
|
||||
var scheme = getScheme()
|
||||
if (scheme == "socks") {
|
||||
proxy_port = "4446"
|
||||
}else{
|
||||
proxy_port = "4444"
|
||||
}
|
||||
if (proxy_port == undefined) {
|
||||
var scheme = getScheme()
|
||||
if (scheme == "socks") {
|
||||
proxy_port = "4446"
|
||||
} else {
|
||||
proxy_port = "4444"
|
||||
}
|
||||
console.log("Got i2p proxy port:", proxy_port);
|
||||
return proxy_port;
|
||||
}
|
||||
console.log("Got i2p proxy port:", proxy_port);
|
||||
return proxy_port;
|
||||
}
|
||||
|
||||
var control_host = "127.0.0.1"
|
||||
|
||||
function getControlHost() {
|
||||
if (control_host == undefined){
|
||||
return "127.0.0.1"
|
||||
}
|
||||
console.log("Got i2p control host:", control_host);
|
||||
return control_host;
|
||||
if (control_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
console.log("Got i2p control host:", control_host);
|
||||
return control_host;
|
||||
}
|
||||
|
||||
var control_port = "4444"
|
||||
|
||||
function getControlPort() {
|
||||
if (control_port == undefined){
|
||||
return "4444"
|
||||
}
|
||||
console.log("Got i2p control port:", control_port);
|
||||
return control_port;
|
||||
if (control_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
console.log("Got i2p control port:", control_port);
|
||||
return control_port;
|
||||
}
|
||||
|
||||
function setupProxy() {
|
||||
var controlHost = getControlHost()
|
||||
var controlPort = getControlPort();
|
||||
var Host = getHost()
|
||||
var Port = getPort()
|
||||
var Scheme = getScheme()
|
||||
function handleProxyRequest(requestInfo) {
|
||||
console.log("proxying request via listener")
|
||||
console.log(" ", Scheme, Host, ":", Port,)
|
||||
return {type: Scheme, host: Host, port: Port, proxyDns: true}
|
||||
var controlHost = getControlHost()
|
||||
var controlPort = getControlPort();
|
||||
var Host = getHost()
|
||||
var Port = getPort()
|
||||
var Scheme = getScheme()
|
||||
function handleProxyRequest(requestInfo) {
|
||||
console.log("proxying request via listener")
|
||||
console.log(" ", Scheme, Host, ":", Port,)
|
||||
return {
|
||||
type: Scheme,
|
||||
host: Host,
|
||||
port: Port,
|
||||
proxyDns: true
|
||||
}
|
||||
console.log("Setting up Firefox WebExtension proxy")
|
||||
browser.proxy.onRequest.addListener(handleProxyRequest, {urls: ["<all_urls>"]});
|
||||
console.log("i2p settings created for WebExtension Proxy")
|
||||
}
|
||||
console.log("Setting up Firefox WebExtension proxy")
|
||||
browser.proxy.onRequest.addListener(handleProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy")
|
||||
}
|
||||
|
||||
function checkStoredSettings(storedSettings) {
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme){
|
||||
defaultSettings["proxy_scheme"] = "http"
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http"
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
}
|
||||
|
||||
function update(restoredSettings) {
|
||||
proxy_scheme = restoredSettings.proxy_scheme
|
||||
console.log("restoring proxy scheme:", proxy_scheme)
|
||||
proxy_host = restoredSettings.proxy_host
|
||||
console.log("restoring proxy host:", proxy_host)
|
||||
proxy_port = restoredSettings.proxy_port
|
||||
console.log("restoring proxy port:", proxy_port)
|
||||
control_host = restoredSettings.control_host
|
||||
console.log("restoring control host:", control_host)
|
||||
control_port = restoredSettings.control_port
|
||||
console.log("restoring control port:", control_port)
|
||||
proxy_scheme = restoredSettings.proxy_scheme
|
||||
console.log("restoring proxy scheme:", proxy_scheme)
|
||||
proxy_host = restoredSettings.proxy_host
|
||||
console.log("restoring proxy host:", proxy_host)
|
||||
proxy_port = restoredSettings.proxy_port
|
||||
console.log("restoring proxy port:", proxy_port)
|
||||
control_host = restoredSettings.control_host
|
||||
console.log("restoring control host:", control_host)
|
||||
control_port = restoredSettings.control_port
|
||||
console.log("restoring control port:", control_port)
|
||||
}
|
||||
|
||||
chrome.storage.local.get(function(got){
|
||||
checkStoredSettings(got)
|
||||
update(got)
|
||||
setupProxy()
|
||||
chrome.storage.local.get(function(got) {
|
||||
checkStoredSettings(got)
|
||||
update(got)
|
||||
setupProxy()
|
||||
});
|
||||
|
||||
// Theme all currently open windows
|
||||
if (!getChrome()) {
|
||||
if (!isDroid()) {
|
||||
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
|
||||
}
|
||||
if (!isDroid()) {
|
||||
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user