update strings
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
"addresstype": { "description": "Address Type:", "message": "Address Type:" },
|
||||
"applicationExplain": {
|
||||
"description": "Description for application section.",
|
||||
"message": "These applications work with I2P directly to provide them with security and privacy."
|
||||
"message": "The I2P router console and applications open in their own tab, providing them with the same security benefits as browsing with this extension. This adds more protection by isolating each application and preventing other tabs ( ie social media, etc ) from fingerprinting or scripts. All tabs use identifying colours to keep track of your I2P workflow."
|
||||
},
|
||||
"applicationHeader": {
|
||||
"description": "Header for applications section.",
|
||||
@@ -185,7 +185,7 @@
|
||||
},
|
||||
"i2ptunnel": {
|
||||
"description": "Description for i2ptunnel",
|
||||
"message": "I2P has a web-based interface for configuring .i2p services like web sites which you can set up."
|
||||
"message": "View proxy status messages and configure services and tunnels."
|
||||
},
|
||||
"i2ptunnelPreface": {
|
||||
"description": "Preface for the browser titlebar",
|
||||
@@ -476,7 +476,7 @@
|
||||
},
|
||||
"routerConsole": {
|
||||
"description": "Description for the router console.",
|
||||
"message": "The entrypoint for all other I2P applications is the I2P Router Console. To visit it, click here."
|
||||
"message": "Access your I2P router console and its full range of applications and configurations."
|
||||
},
|
||||
"routerPreface": {
|
||||
"description": "Preface for the browser titlebar",
|
||||
@@ -512,7 +512,7 @@
|
||||
},
|
||||
"snark": {
|
||||
"description": "Description for Bittorrent",
|
||||
"message": "I2P is capable of anonymous Peer-to-Peer file sharing using the built-in bittorrent application."
|
||||
"message": "Quick access to Snark, the Peer-to-peer I2P network specific file sharing application."
|
||||
},
|
||||
"sourcehead": {
|
||||
"description": "Get the source code:",
|
||||
@@ -524,7 +524,7 @@
|
||||
},
|
||||
"susimail": {
|
||||
"description": "Description for e-mail",
|
||||
"message": "I2P also bundles a webmail client which can be used to access in-I2P e-mail."
|
||||
"message": "Quick access to the SusiMail I2P network email client."
|
||||
},
|
||||
"text-section-header": {
|
||||
"description": "The Invisible Internet Browser",
|
||||
|
4
home.css
4
home.css
@@ -220,8 +220,8 @@ button {
|
||||
min-height: 5rem;
|
||||
padding: .5rem;
|
||||
margin: .5rem;
|
||||
width: 100%;
|
||||
min-width: 100%
|
||||
width: 98%;
|
||||
min-width: 98%
|
||||
}
|
||||
#proxyReady {
|
||||
min-height: 3rem;
|
||||
|
@@ -14,7 +14,7 @@
|
||||
<div class='background'>
|
||||
<div class='content'>
|
||||
<div class="text-section-header">
|
||||
<img width="30px" height="30px" src="icons/i2plogo.png"/>
|
||||
<img height="30px" src="icons/i2plogo.png" width="30px">
|
||||
<h1 id="text-section-header">I2P Browsing</h1>
|
||||
</div>
|
||||
|
||||
|
360
host.js
360
host.js
@@ -1,202 +1,204 @@
|
||||
function proxyHost(requestDetails) {
|
||||
if (requestDetails.originUrl != browser.runtime.getURL("window.html")) {} else if (requestDetails.originUrl != browser.runtime.getURL("home.html")) {} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
let hostname = "";
|
||||
if (requestDetails.url.indexOf("://") > -1) {
|
||||
hostname = requestDetails.url.split("/")[2];
|
||||
} else {
|
||||
hostname = requestDetails.url.split("/")[0];
|
||||
}
|
||||
console.warn("(host) hostname", hostname);
|
||||
if (hostname == "proxy.i2p") {
|
||||
console.warn("(host) is proxy.i2p", hostname);
|
||||
return true;
|
||||
}
|
||||
|
||||
console.warn("(host) requestDetails", requestDetails.url);
|
||||
if (
|
||||
hostname == "c6lilt4cr5x7jifxridpkesf2zgfwqfchtp6laihr4pdqomq25iq.b32.i2p"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (requestDetails.originUrl != browser.runtime.getURL("window.html")) {
|
||||
} else if (requestDetails.originUrl != browser.runtime.getURL("home.html")) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
let hostname = "";
|
||||
if (requestDetails.url.indexOf("://") > -1) {
|
||||
hostname = requestDetails.url.split("/")[2];
|
||||
} else {
|
||||
hostname = requestDetails.url.split("/")[0];
|
||||
}
|
||||
console.warn("(host) hostname", hostname);
|
||||
if (hostname == "proxy.i2p") {
|
||||
console.warn("(host) is proxy.i2p", hostname);
|
||||
return true;
|
||||
}
|
||||
|
||||
console.warn("(host) requestDetails", requestDetails.url);
|
||||
if (
|
||||
hostname == "c6lilt4cr5x7jifxridpkesf2zgfwqfchtp6laihr4pdqomq25iq.b32.i2p"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function localHost(url) {
|
||||
let hostname = "";
|
||||
if (url.indexOf("://") > -1) {
|
||||
hostname = url.split("/")[2];
|
||||
} else {
|
||||
hostname = url.split("/")[0];
|
||||
}
|
||||
hostname = hostname.split(":")[0];
|
||||
console.log("(urlcheck) hostname localhost", hostname);
|
||||
console.log("(urlcheck) url localhost", url);
|
||||
if (hostname === "127.0.0.1") {
|
||||
if (url.indexOf(":8084") != -1) return "blog";
|
||||
if (url.indexOf(":7669") != -1) return "irc";
|
||||
if (url.indexOf(":7695") != -1) return "tor";
|
||||
} else if (hostname === "localhost") {
|
||||
if (url.indexOf(":8084") != -1) return "blog";
|
||||
if (url.indexOf(":7669") != -1) return "irc";
|
||||
if (url.indexOf(":7695") != -1) return "tor";
|
||||
}
|
||||
let hostname = "";
|
||||
if (url.indexOf("://") > -1) {
|
||||
hostname = url.split("/")[2];
|
||||
} else {
|
||||
hostname = url.split("/")[0];
|
||||
}
|
||||
hostname = hostname.split(":")[0];
|
||||
console.log("(urlcheck) hostname localhost", hostname);
|
||||
console.log("(urlcheck) url localhost", url);
|
||||
if (hostname === "127.0.0.1") {
|
||||
if (url.indexOf(":8084") != -1) return "blog";
|
||||
if (url.indexOf(":7669") != -1) return "irc";
|
||||
if (url.indexOf(":7695") != -1) return "tor";
|
||||
} else if (hostname === "localhost") {
|
||||
if (url.indexOf(":8084") != -1) return "blog";
|
||||
if (url.indexOf(":7669") != -1) return "irc";
|
||||
if (url.indexOf(":7695") != -1) return "tor";
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
function extensionHost(url) {
|
||||
var prefix = browser.runtime
|
||||
.getURL("")
|
||||
.replace("moz-extension://", "")
|
||||
.replace("/", "");
|
||||
if (url.originUrl !== undefined) {
|
||||
var originUrl = url.originUrl
|
||||
.replace("moz-extension://", "")
|
||||
.replace("/", "");
|
||||
// console.log("(urlcheck) Extension application path", originUrl);
|
||||
// console.log("(urlcheck) Extension application path", prefix);
|
||||
var res = originUrl.startsWith(prefix);
|
||||
// console.log("(urlcheck) Extension application path", res);
|
||||
if (res) return res;
|
||||
}
|
||||
if (url.documentUrl !== undefined) {
|
||||
// console.log("(urlcheck) Extension application path", originUrl);
|
||||
// console.log("(urlcheck) Extension application path", prefix);
|
||||
var res = originUrl.startsWith(prefix);
|
||||
// console.log("(urlcheck) Extension application path", res);
|
||||
if (res) return res;
|
||||
}
|
||||
console.log("(urlcheck) Extension application path", url);
|
||||
var prefix = browser.runtime
|
||||
.getURL("")
|
||||
.replace("moz-extension://", "")
|
||||
.replace("/", "");
|
||||
if (url.originUrl !== undefined) {
|
||||
var originUrl = url.originUrl
|
||||
.replace("moz-extension://", "")
|
||||
.replace("/", "");
|
||||
// console.log("(urlcheck) Extension application path", originUrl);
|
||||
// console.log("(urlcheck) Extension application path", prefix);
|
||||
var res = originUrl.startsWith(prefix);
|
||||
// console.log("(urlcheck) Extension application path", res);
|
||||
if (res) return res;
|
||||
}
|
||||
if (url.documentUrl !== undefined) {
|
||||
// console.log("(urlcheck) Extension application path", originUrl);
|
||||
// console.log("(urlcheck) Extension application path", prefix);
|
||||
var res = originUrl.startsWith(prefix);
|
||||
// console.log("(urlcheck) Extension application path", res);
|
||||
if (res) return res;
|
||||
}
|
||||
console.log("(urlcheck) Extension application path", url);
|
||||
}
|
||||
|
||||
function i2pHostName(url) {
|
||||
let hostname = "";
|
||||
console.log("(hosts)", url);
|
||||
let u = new URL(url);
|
||||
if (u.host.endsWith(".i2p")) {
|
||||
hostname = u.host;
|
||||
} else if (url.includes("=")) {
|
||||
if (url.includes(".i2p")) {
|
||||
lsit = url.split("=");
|
||||
for (let item in lsit) {
|
||||
var items = lsit[item].split(`\ % `); //"\%")
|
||||
for (let p in items) {
|
||||
if (items[p].includes(".i2p")) {
|
||||
hostname = items[p].replace("3D", 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (hostname != "") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hostname = "";
|
||||
console.log("(hosts)", url);
|
||||
let u = new URL(url);
|
||||
if (u.host.endsWith(".i2p")) {
|
||||
hostname = u.host;
|
||||
} else if (url.includes("=")) {
|
||||
if (url.includes(".i2p")) {
|
||||
lsit = url.split("=");
|
||||
for (let item in lsit) {
|
||||
var items = lsit[item].split(`\ % `); //"\%")
|
||||
for (let p in items) {
|
||||
if (items[p].includes(".i2p")) {
|
||||
hostname = items[p].replace("3D", 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (url.indexOf("://") > -1) {
|
||||
hostname = url.split("/")[2];
|
||||
} else {
|
||||
hostname = url.split("/")[0];
|
||||
if (hostname != "") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log("(hosts) scrub", hostname);
|
||||
return hostname;
|
||||
} else if (url.indexOf("://") > -1) {
|
||||
hostname = url.split("/")[2];
|
||||
} else {
|
||||
hostname = url.split("/")[0];
|
||||
}
|
||||
console.log("(hosts) scrub", hostname);
|
||||
return hostname;
|
||||
}
|
||||
|
||||
function i2pHost(url) {
|
||||
if (proxyHost(url)) {
|
||||
console.warn("(host) proxy.i2p", url.url);
|
||||
return false;
|
||||
}
|
||||
let hostname = i2pHostName(url.url);
|
||||
let postname = hostname.split(":")[0];
|
||||
if (postname.endsWith("proxy.i2p")) {
|
||||
return false;
|
||||
}
|
||||
return postname.endsWith(".i2p");
|
||||
if (proxyHost(url)) {
|
||||
console.warn("(host) proxy.i2p", url.url);
|
||||
return false;
|
||||
}
|
||||
let hostname = i2pHostName(url.url);
|
||||
let postname = hostname.split(":")[0];
|
||||
if (postname.endsWith("proxy.i2p")) {
|
||||
return false;
|
||||
}
|
||||
return postname.endsWith(".i2p");
|
||||
}
|
||||
|
||||
function routerHost(url) {
|
||||
// console.log("(urlcheck) HOST URL CHECK");
|
||||
let hostname = "";
|
||||
let path = "";
|
||||
// console.log("(urlcheck) HOST URL CHECK");
|
||||
let hostname = "";
|
||||
let path = "";
|
||||
|
||||
function pathcheck(str) {
|
||||
if (str != undefined) {
|
||||
let final = str.split("/")[0];
|
||||
if (final === "i2ptunnelmgr" || final === "i2ptunnel") {
|
||||
console.log("(urlcheck) Tunnel application path", final);
|
||||
return "i2ptunnelmgr";
|
||||
} else if (
|
||||
final === "i2psnark" ||
|
||||
final === "torrents" ||
|
||||
final.startsWith("transmission") ||
|
||||
final.startsWith("tracker") ||
|
||||
url.includes(":7662")
|
||||
) {
|
||||
console.log("(urlcheck) Torrent application path", final);
|
||||
return "i2psnark";
|
||||
} else if (final === "webmail" || final === "susimail") {
|
||||
if (!url.includes(".css")) {
|
||||
console.log("(urlcheck) Mail application path", final);
|
||||
return "webmail";
|
||||
}
|
||||
} else if (final.startsWith("MuWire")) {
|
||||
if (!url.includes(".png")) {
|
||||
console.log("(urlcheck) MuWire application path", final);
|
||||
return "muwire";
|
||||
}
|
||||
} else if (final.startsWith("i2pbote")) {
|
||||
if (!url.includes(".png")) {
|
||||
console.log("(urlcheck) I2PBote application path", final);
|
||||
return "i2pbote";
|
||||
}
|
||||
} else if (
|
||||
final === "home" ||
|
||||
final === "console" ||
|
||||
final === "dns" ||
|
||||
final === "susidns" ||
|
||||
final.startsWith("susidns") ||
|
||||
final === "sitemap" ||
|
||||
final.startsWith("config")
|
||||
) {
|
||||
console.log("(urlcheck) Console application path", final);
|
||||
return "routerconsole";
|
||||
}
|
||||
function pathcheck(str) {
|
||||
if (str != undefined) {
|
||||
let final = str.split("/")[0];
|
||||
if (final === "i2ptunnelmgr" || final === "i2ptunnel") {
|
||||
console.log("(urlcheck) Tunnel application path", final);
|
||||
return "i2ptunnelmgr";
|
||||
} else if (
|
||||
final === "i2psnark" ||
|
||||
final === "torrents" ||
|
||||
final.startsWith("transmission") ||
|
||||
final.startsWith("tracker") ||
|
||||
url.includes(":7662")
|
||||
) {
|
||||
console.log("(urlcheck) Torrent application path", final);
|
||||
return "i2psnark";
|
||||
} else if (final === "webmail" || final === "susimail") {
|
||||
if (!url.includes(".css")) {
|
||||
console.log("(urlcheck) Mail application path", final);
|
||||
return "webmail";
|
||||
}
|
||||
return true;
|
||||
} else if (final.startsWith("MuWire")) {
|
||||
if (!url.includes(".png")) {
|
||||
console.log("(urlcheck) MuWire application path", final);
|
||||
return "muwire";
|
||||
}
|
||||
} else if (final.startsWith("i2pbote")) {
|
||||
if (!url.includes(".png")) {
|
||||
console.log("(urlcheck) I2PBote application path", final);
|
||||
return "i2pbote";
|
||||
}
|
||||
} else if (
|
||||
final === "home" ||
|
||||
final === "console" ||
|
||||
final === "dns" ||
|
||||
final === "susidns" ||
|
||||
final.startsWith("susidns") ||
|
||||
final === "sitemap" ||
|
||||
final.startsWith("config")
|
||||
) {
|
||||
console.log("(urlcheck) Console application path", final);
|
||||
return "routerconsole";
|
||||
}
|
||||
}
|
||||
if (url.indexOf("://") > -1) {
|
||||
hostname = url.split("/")[2];
|
||||
let prefix = url.substr(0, url.indexOf("://") + 3);
|
||||
path = url.replace(prefix + hostname + "/", "");
|
||||
} else if (identifyProtocolHandler(url)) {
|
||||
let newurl = identifyProtocolHandler(url);
|
||||
return routerHost(newurl);
|
||||
} else {
|
||||
hostname = url.split("/")[0];
|
||||
path = url.replace(hostname + "/", "");
|
||||
}
|
||||
if (hostname === control_host + ":" + control_port) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "localhost" + ":" + control_port) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "127.0.0.1" + ":" + control_port) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "localhost" + ":" + 7070) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "127.0.0.1" + ":" + 7070) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "localhost" + ":" + 7667) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "127.0.0.1" + ":" + 7667) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (url.indexOf("://") > -1) {
|
||||
hostname = url.split("/")[2];
|
||||
let prefix = url.substr(0, url.indexOf("://") + 3);
|
||||
path = url.replace(prefix + hostname + "/", "");
|
||||
} else if (identifyProtocolHandler(url)) {
|
||||
let newurl = identifyProtocolHandler(url);
|
||||
return routerHost(newurl);
|
||||
} else {
|
||||
hostname = url.split("/")[0];
|
||||
path = url.replace(hostname + "/", "");
|
||||
}
|
||||
if (hostname === control_host + ":" + control_port) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "localhost" + ":" + control_port) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "127.0.0.1" + ":" + control_port) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "localhost" + ":" + 7070) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "127.0.0.1" + ":" + 7070) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "localhost" + ":" + 7667) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "127.0.0.1" + ":" + 7667) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
888
proxy.js
888
proxy.js
@@ -14,521 +14,521 @@ var torpref = chrome.i18n.getMessage("torPreface");
|
||||
var torprefpriv = chrome.i18n.getMessage("torPreface");
|
||||
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: true,
|
||||
value: true,
|
||||
});
|
||||
|
||||
chrome.privacy.network.networkPredictionEnabled.set({
|
||||
value: false,
|
||||
value: false,
|
||||
});
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp",
|
||||
value: "disable_non_proxied_udp",
|
||||
});
|
||||
console.log("Disabled unproxied UDP.");
|
||||
|
||||
function shouldProxyRequest(requestInfo) {
|
||||
return requestInfo.parentFrameId != -1;
|
||||
return requestInfo.parentFrameId != -1;
|
||||
}
|
||||
|
||||
var handleContextProxyRequest = async function(requestDetails) {
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
console.warn("(proxy) is proxy check")
|
||||
return proxy;
|
||||
}
|
||||
var handleContextProxyRequest = async function (requestDetails) {
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
console.warn("(proxy) is proxy check");
|
||||
return proxy;
|
||||
}
|
||||
|
||||
function ircProxy() {
|
||||
if (!requestDetails.url.includes("7669")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
if (requestDetails.url.includes(":7669")) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
}
|
||||
function ircProxy() {
|
||||
if (!requestDetails.url.includes("7669")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
/* This is **NOT** the tor SOCKS5 proxy.
|
||||
if (requestDetails.url.includes(":7669")) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
/* This is **NOT** the tor SOCKS5 proxy.
|
||||
These are the rules for visiting the SOCKS5 proxy manager.
|
||||
*/
|
||||
function torProxy() {
|
||||
if (!requestDetails.url.includes("7695")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
if (requestDetails.url.includes(":7695")) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
}
|
||||
function torProxy() {
|
||||
if (!requestDetails.url.includes("7695")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
|
||||
function blogProxy() {
|
||||
if (!requestDetails.url.includes("8084")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
if (requestDetails.url.includes(":8084")) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
}
|
||||
if (requestDetails.url.includes(":7695")) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
|
||||
function btProxy() {
|
||||
proxy = routerProxy();
|
||||
if (requestDetails.url.includes(":7662")) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
}
|
||||
console.log("(bt proxy)", proxy);
|
||||
function blogProxy() {
|
||||
if (!requestDetails.url.includes("8084")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
if (requestDetails.url.includes(":8084")) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
|
||||
function btProxy() {
|
||||
proxy = routerProxy();
|
||||
if (requestDetails.url.includes(":7662")) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
}
|
||||
console.log("(bt proxy)", proxy);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
function mainProxy() {
|
||||
console.log("(proxy) mainproxy 0");
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
let url = new URL(requestDetails.url);
|
||||
if (
|
||||
requestDetails.url.startsWith(
|
||||
"http://" + getHost() + ":" + getConsolePort() + "/i2psnark/"
|
||||
)
|
||||
) {
|
||||
//+url.host)) {
|
||||
console.log("(proxy) mainproxy 2", url);
|
||||
proxy = null;
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
function routerProxy() {
|
||||
if (routerHost(requestDetails.url)) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
} else if (!routerHost(requestDetails.url)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
try {
|
||||
var handleProxyRequest = function (context) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
|
||||
if (context == "firefox-default" || context == "firefox-private") {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
|
||||
function mainProxy() {
|
||||
console.log("(proxy) mainproxy 0");
|
||||
proxy = {
|
||||
// eslint-disable-next-line no-negated-condition
|
||||
if (context != undefined) {
|
||||
console.log("(proxy), context", context);
|
||||
if (context.name == ircpref) {
|
||||
proxy = ircProxy();
|
||||
return proxy;
|
||||
} else if (context.name == torpref) {
|
||||
proxy = torProxy();
|
||||
return proxy;
|
||||
} else if (context.name == blogpref) {
|
||||
proxy = blogProxy();
|
||||
return proxy;
|
||||
} else if (context.name == titlepref) {
|
||||
proxy = mainProxy();
|
||||
return proxy;
|
||||
} else if (context.name == routerpref) {
|
||||
proxy = routerProxy();
|
||||
return proxy;
|
||||
} else if (context.name == torrentpref) {
|
||||
proxy = btProxy();
|
||||
return proxy;
|
||||
} else if (context.name == mailpref) {
|
||||
proxy = routerProxy();
|
||||
return proxy;
|
||||
} else if (context.name == tunnelpref) {
|
||||
proxy = routerProxy();
|
||||
return proxy;
|
||||
} else if (context.name == muwirepref) {
|
||||
proxy = routerProxy();
|
||||
return proxy;
|
||||
} else if (context.name == botepref) {
|
||||
proxy = routerProxy();
|
||||
return proxy;
|
||||
}
|
||||
} else {
|
||||
if (!routerHost(requestDetails.url)) {
|
||||
if (localHost(requestDetails.url)) {
|
||||
if (requestDetails.url.includes(":7669")) {
|
||||
proxy = null;
|
||||
} else if (requestDetails.url.includes(":7662")) {
|
||||
proxy = null;
|
||||
} else if (requestDetails.url.includes(":7695")) {
|
||||
proxy = null;
|
||||
} else {
|
||||
console.log(
|
||||
"(proxy) non-routerconsole localhost url, will not interfere",
|
||||
requestDetails.url
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i2pHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
let url = new URL(requestDetails.url);
|
||||
if (
|
||||
requestDetails.url.startsWith(
|
||||
"http://" + getHost() + ":" + getConsolePort() + "/i2psnark/"
|
||||
)
|
||||
) {
|
||||
//+url.host)) {
|
||||
console.log("(proxy) mainproxy 2", url);
|
||||
proxy = null;
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
function routerProxy() {
|
||||
if (routerHost(requestDetails.url)) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
} else if (!routerHost(requestDetails.url)) {
|
||||
};
|
||||
} else {
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
} else {
|
||||
proxy = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
var handleProxyRequest = function(context) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
|
||||
if (context == "firefox-default" || context == "firefox-private") {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-negated-condition
|
||||
if (context != undefined) {
|
||||
console.log("(proxy), context", context);
|
||||
if (context.name == ircpref) {
|
||||
proxy = ircProxy();
|
||||
return proxy;
|
||||
} else if (context.name == torpref) {
|
||||
proxy = torProxy();
|
||||
return proxy;
|
||||
} else if (context.name == blogpref) {
|
||||
proxy = blogProxy();
|
||||
return proxy;
|
||||
} else if (context.name == titlepref) {
|
||||
proxy = mainProxy();
|
||||
return proxy;
|
||||
} else if (context.name == routerpref) {
|
||||
proxy = routerProxy();
|
||||
return proxy;
|
||||
} else if (context.name == torrentpref) {
|
||||
proxy = btProxy();
|
||||
return proxy;
|
||||
} else if (context.name == mailpref) {
|
||||
proxy = routerProxy();
|
||||
return proxy;
|
||||
} else if (context.name == tunnelpref) {
|
||||
proxy = routerProxy();
|
||||
return proxy;
|
||||
} else if (context.name == muwirepref) {
|
||||
proxy = routerProxy();
|
||||
return proxy;
|
||||
} else if (context.name == botepref) {
|
||||
proxy = routerProxy();
|
||||
return proxy;
|
||||
}
|
||||
} else {
|
||||
if (!routerHost(requestDetails.url)) {
|
||||
if (localHost(requestDetails.url)) {
|
||||
if (requestDetails.url.includes(":7669")) {
|
||||
proxy = null;
|
||||
} else if (requestDetails.url.includes(":7662")) {
|
||||
proxy = null;
|
||||
} else if (requestDetails.url.includes(":7695")) {
|
||||
proxy = null;
|
||||
} else {
|
||||
console.log(
|
||||
"(proxy) non-routerconsole localhost url, will not interfere",
|
||||
requestDetails.url
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i2pHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
} else {
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
} else {
|
||||
proxy = null;
|
||||
}
|
||||
}
|
||||
if (requestDetails.url.includes("rpc")) {
|
||||
console.log("(proxy for rpc url)", rpc);
|
||||
}
|
||||
/* var tab = tabGet(requestDetails.tabId);
|
||||
if (requestDetails.url.includes("rpc")) {
|
||||
console.log("(proxy for rpc url)", rpc);
|
||||
}
|
||||
/* var tab = tabGet(requestDetails.tabId);
|
||||
tab.then(handleTabRequest,) */
|
||||
return proxy;
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
};
|
||||
var contextGet = async function (tabInfo) {
|
||||
try {
|
||||
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
|
||||
return context;
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
return "firefox-default";
|
||||
}
|
||||
};
|
||||
var tabGet = async function (tabId) {
|
||||
try {
|
||||
let tabInfo = await browser.tabs.get(tabId);
|
||||
return tabInfo;
|
||||
} catch (error) {
|
||||
console.log("(proxy)Tab error", error);
|
||||
}
|
||||
};
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
if (requestDetails.originUrl == browser.runtime.getURL("security.html")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
if (
|
||||
requestDetails.cookieStoreId == "firefox-default" ||
|
||||
requestDetails.cookieStoreId == "firefox-private"
|
||||
) {
|
||||
if (browser.windows != undefined) {
|
||||
return browser.proxy.settings.get({});
|
||||
}
|
||||
}
|
||||
if (requestDetails.tabId > 0) {
|
||||
if (requestDetails.url.includes("MuWire")) {
|
||||
return;
|
||||
}
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
var contextGet = async function(tabInfo) {
|
||||
try {
|
||||
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
|
||||
return context;
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
return "firefox-default";
|
||||
}
|
||||
};
|
||||
var tabGet = async function(tabId) {
|
||||
try {
|
||||
let tabInfo = await browser.tabs.get(tabId);
|
||||
return tabInfo;
|
||||
} catch (error) {
|
||||
console.log("(proxy)Tab error", error);
|
||||
}
|
||||
};
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
if (requestDetails.originUrl == browser.runtime.getURL("security.html")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
if (
|
||||
requestDetails.cookieStoreId == "firefox-default" ||
|
||||
requestDetails.cookieStoreId == "firefox-private"
|
||||
) {
|
||||
if (browser.windows != undefined) {
|
||||
return browser.proxy.settings.get({});
|
||||
}
|
||||
}
|
||||
if (requestDetails.tabId > 0) {
|
||||
if (requestDetails.url.includes("MuWire")) {
|
||||
return;
|
||||
}
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
} else if (i2pHost(requestDetails)) {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
requestDetails.tabId = tab;
|
||||
var context = tab.then(contextGet);
|
||||
var proxy = await context.then(handleProxyRequest);
|
||||
//console.log('(proxy)Returning I2P Proxy', proxy);
|
||||
return proxy;
|
||||
} else if (extensionHost(requestDetails)) {
|
||||
return;
|
||||
} else {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var context = tab.then(contextGet);
|
||||
var proxy = await context.then(handleProxyRequest);
|
||||
//console.log("(proxy)Returning I2P Proxy", proxy);
|
||||
return proxy;
|
||||
}
|
||||
/*proxy = {};
|
||||
return proxy;
|
||||
} else if (i2pHost(requestDetails)) {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
requestDetails.tabId = tab;
|
||||
var context = tab.then(contextGet);
|
||||
var proxy = await context.then(handleProxyRequest);
|
||||
//console.log('(proxy)Returning I2P Proxy', proxy);
|
||||
return proxy;
|
||||
} else if (extensionHost(requestDetails)) {
|
||||
return;
|
||||
} else {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var context = tab.then(contextGet);
|
||||
var proxy = await context.then(handleProxyRequest);
|
||||
//console.log("(proxy)Returning I2P Proxy", proxy);
|
||||
return proxy;
|
||||
}
|
||||
/*proxy = {};
|
||||
console.log("(proxy)Returning unset Proxy", proxy);
|
||||
return proxy;*/
|
||||
} else {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
//console.log('(proxy for rpc url)', rpc);
|
||||
return proxy;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(proxy)Not using I2P Proxy.", error);
|
||||
} else {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
//console.log('(proxy for rpc url)', rpc);
|
||||
return proxy;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(proxy)Not using I2P Proxy.", error);
|
||||
}
|
||||
};
|
||||
|
||||
function SetupSettings() {
|
||||
console.log("Initialising Settings");
|
||||
console.log("Initialising Settings");
|
||||
|
||||
function onSetupError() {
|
||||
console.log("Settings initialization error");
|
||||
function onSetupError() {
|
||||
console.log("Settings initialization error");
|
||||
}
|
||||
//
|
||||
function checkSchemeStoredSettings(storedSettings) {
|
||||
if (storedSettings.proxy_scheme == undefined) {
|
||||
storedSettings.proxy_scheme = "http";
|
||||
} else {
|
||||
proxy_scheme = storedSettings.proxy_scheme;
|
||||
}
|
||||
//
|
||||
function checkSchemeStoredSettings(storedSettings) {
|
||||
if (storedSettings.proxy_scheme == undefined) {
|
||||
storedSettings.proxy_scheme = "http";
|
||||
} else {
|
||||
proxy_scheme = storedSettings.proxy_scheme;
|
||||
}
|
||||
|
||||
console.log("Initialising Proxy Scheme", storedSettings.proxy_scheme);
|
||||
setupProxy();
|
||||
console.log("Initialising Proxy Scheme", storedSettings.proxy_scheme);
|
||||
setupProxy();
|
||||
}
|
||||
var gettingSchemeStoredSettings = browser.storage.local.get("proxy_scheme");
|
||||
gettingSchemeStoredSettings.then(checkSchemeStoredSettings, onSetupError);
|
||||
|
||||
//
|
||||
function checkHostStoredSettings(storedSettings) {
|
||||
if (storedSettings.proxy_host == undefined) {
|
||||
storedSettings.proxy_host = "127.0.0.1";
|
||||
} else {
|
||||
proxy_host = storedSettings.proxy_host;
|
||||
}
|
||||
var gettingSchemeStoredSettings = browser.storage.local.get("proxy_scheme");
|
||||
gettingSchemeStoredSettings.then(checkSchemeStoredSettings, onSetupError);
|
||||
|
||||
//
|
||||
function checkHostStoredSettings(storedSettings) {
|
||||
if (storedSettings.proxy_host == undefined) {
|
||||
storedSettings.proxy_host = "127.0.0.1";
|
||||
} else {
|
||||
proxy_host = storedSettings.proxy_host;
|
||||
}
|
||||
console.log("Initialising Host", storedSettings.proxy_host);
|
||||
setupProxy();
|
||||
}
|
||||
var gettingHostStoredSettings = browser.storage.local.get("proxy_host");
|
||||
gettingHostStoredSettings.then(checkHostStoredSettings, onSetupError);
|
||||
|
||||
console.log("Initialising Host", storedSettings.proxy_host);
|
||||
setupProxy();
|
||||
//
|
||||
function checkPortStoredSettings(storedSettings) {
|
||||
if (storedSettings.proxy_port == undefined) {
|
||||
storedSettings.proxy_port = "4444";
|
||||
} else {
|
||||
proxy_port = storedSettings.proxy_port;
|
||||
}
|
||||
var gettingHostStoredSettings = browser.storage.local.get("proxy_host");
|
||||
gettingHostStoredSettings.then(checkHostStoredSettings, onSetupError);
|
||||
|
||||
//
|
||||
function checkPortStoredSettings(storedSettings) {
|
||||
if (storedSettings.proxy_port == undefined) {
|
||||
storedSettings.proxy_port = "4444";
|
||||
} else {
|
||||
proxy_port = storedSettings.proxy_port;
|
||||
}
|
||||
console.log("Initialising Port", storedSettings.proxy_port);
|
||||
setupProxy();
|
||||
}
|
||||
var gettingPortStoredSettings = browser.storage.local.get("proxy_port");
|
||||
gettingPortStoredSettings.then(checkPortStoredSettings, onSetupError);
|
||||
|
||||
console.log("Initialising Port", storedSettings.proxy_port);
|
||||
setupProxy();
|
||||
//
|
||||
function checkControlHostStoredSettings(storedSettings) {
|
||||
if (storedSettings.control_host == undefined) {
|
||||
storedSettings.control_host = "127.0.0.1";
|
||||
} else {
|
||||
control_host = storedSettings.control_host;
|
||||
}
|
||||
var gettingPortStoredSettings = browser.storage.local.get("proxy_port");
|
||||
gettingPortStoredSettings.then(checkPortStoredSettings, onSetupError);
|
||||
|
||||
//
|
||||
function checkControlHostStoredSettings(storedSettings) {
|
||||
if (storedSettings.control_host == undefined) {
|
||||
storedSettings.control_host = "127.0.0.1";
|
||||
} else {
|
||||
control_host = storedSettings.control_host;
|
||||
}
|
||||
console.log("Initialising Control Host", storedSettings.control_host);
|
||||
setupProxy();
|
||||
}
|
||||
var gettingControlHostStoredSettings =
|
||||
browser.storage.local.get("control_host");
|
||||
gettingControlHostStoredSettings.then(
|
||||
checkControlHostStoredSettings,
|
||||
onSetupError
|
||||
);
|
||||
|
||||
console.log("Initialising Control Host", storedSettings.control_host);
|
||||
setupProxy();
|
||||
//
|
||||
function checkControlPortStoredSettings(storedSettings) {
|
||||
if (storedSettings.control_port == undefined) {
|
||||
storedSettings.control_port = "7657";
|
||||
} else {
|
||||
control_port = storedSettings.control_port;
|
||||
}
|
||||
var gettingControlHostStoredSettings =
|
||||
browser.storage.local.get("control_host");
|
||||
gettingControlHostStoredSettings.then(
|
||||
checkControlHostStoredSettings,
|
||||
onSetupError
|
||||
|
||||
console.log("Initialising Control Port", storedSettings.control_port);
|
||||
setupProxy();
|
||||
}
|
||||
var gettingControlPortStoredSettings =
|
||||
browser.storage.local.get("control_port");
|
||||
gettingControlPortStoredSettings.then(
|
||||
checkControlPortStoredSettings,
|
||||
onSetupError
|
||||
);
|
||||
|
||||
//
|
||||
function checkHistoryStoredSettings(storedSettings) {
|
||||
if (storedSettings.disable_history == undefined) {
|
||||
storedSettings.disable_history = false;
|
||||
} else {
|
||||
disable_history = storedSettings.disable_history;
|
||||
}
|
||||
|
||||
console.log(
|
||||
"Initialising Disabled History",
|
||||
storedSettings.disable_history
|
||||
);
|
||||
|
||||
//
|
||||
function checkControlPortStoredSettings(storedSettings) {
|
||||
if (storedSettings.control_port == undefined) {
|
||||
storedSettings.control_port = "7657";
|
||||
} else {
|
||||
control_port = storedSettings.control_port;
|
||||
}
|
||||
|
||||
console.log("Initialising Control Port", storedSettings.control_port);
|
||||
setupProxy();
|
||||
}
|
||||
var gettingControlPortStoredSettings =
|
||||
browser.storage.local.get("control_port");
|
||||
gettingControlPortStoredSettings.then(
|
||||
checkControlPortStoredSettings,
|
||||
onSetupError
|
||||
);
|
||||
|
||||
//
|
||||
function checkHistoryStoredSettings(storedSettings) {
|
||||
if (storedSettings.disable_history == undefined) {
|
||||
storedSettings.disable_history = false;
|
||||
} else {
|
||||
disable_history = storedSettings.disable_history;
|
||||
}
|
||||
|
||||
console.log(
|
||||
"Initialising Disabled History",
|
||||
storedSettings.disable_history
|
||||
);
|
||||
setupProxy();
|
||||
}
|
||||
var gettingHistoryStoredSettings =
|
||||
browser.storage.local.get("disable_history");
|
||||
gettingHistoryStoredSettings.then(checkHistoryStoredSettings, onSetupError);
|
||||
setupProxy();
|
||||
}
|
||||
var gettingHistoryStoredSettings =
|
||||
browser.storage.local.get("disable_history");
|
||||
gettingHistoryStoredSettings.then(checkHistoryStoredSettings, onSetupError);
|
||||
}
|
||||
|
||||
function getScheme() {
|
||||
if (proxy_scheme == "HTTP") {
|
||||
return "http";
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
return "socks";
|
||||
}
|
||||
if (proxy_scheme == "http") {
|
||||
return "http";
|
||||
}
|
||||
if (proxy_scheme == "socks") {
|
||||
return "socks";
|
||||
} else {
|
||||
return "http";
|
||||
}
|
||||
if (proxy_scheme == "HTTP") {
|
||||
return "http";
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
return "socks";
|
||||
}
|
||||
if (proxy_scheme == "http") {
|
||||
return "http";
|
||||
}
|
||||
if (proxy_scheme == "socks") {
|
||||
return "socks";
|
||||
} else {
|
||||
return "http";
|
||||
}
|
||||
}
|
||||
|
||||
function getHost() {
|
||||
if (proxy_host == undefined) {
|
||||
proxy_host = "127.0.0.1";
|
||||
}
|
||||
return proxy_host;
|
||||
if (proxy_host == undefined) {
|
||||
proxy_host = "127.0.0.1";
|
||||
}
|
||||
return proxy_host;
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
return proxy_port;
|
||||
}
|
||||
return proxy_port;
|
||||
}
|
||||
|
||||
function getConsolePort() {
|
||||
if (control_port == undefined) {
|
||||
var scheme = getScheme();
|
||||
if (scheme == "socks") {
|
||||
proxy_port = "7657";
|
||||
} else {
|
||||
control_port = "7657";
|
||||
}
|
||||
if (control_port == undefined) {
|
||||
var scheme = getScheme();
|
||||
if (scheme == "socks") {
|
||||
proxy_port = "7657";
|
||||
} else {
|
||||
control_port = "7657";
|
||||
}
|
||||
return control_port;
|
||||
}
|
||||
return control_port;
|
||||
}
|
||||
|
||||
function setupProxy() {
|
||||
console.log("Setting up Firefox WebExtension proxy");
|
||||
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
|
||||
urls: ["<all_urls>"],
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy");
|
||||
browser.proxy.onError.addListener(handleContextProxyError);
|
||||
console.log("Setting up Firefox WebExtension proxy");
|
||||
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
|
||||
urls: ["<all_urls>"],
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy");
|
||||
browser.proxy.onError.addListener(handleContextProxyError);
|
||||
}
|
||||
|
||||
function handleContextProxyError(err) {
|
||||
function changeTabErr(error) {
|
||||
console.error(`(proxy) Error : ${error}`);
|
||||
}
|
||||
function changeTabErr(error) {
|
||||
console.error(`(proxy) Error : ${error}`);
|
||||
}
|
||||
|
||||
if (err.message === 'ProxyInfoData: Invalid proxy server type: "undefined"') {
|
||||
return;
|
||||
} else {
|
||||
console.warn("(proxy) Error:", err);
|
||||
}
|
||||
if (err.message === 'ProxyInfoData: Invalid proxy server type: "undefined"') {
|
||||
return;
|
||||
} else {
|
||||
console.warn("(proxy) Error:", err);
|
||||
}
|
||||
|
||||
function changeTabPage(tabs) {
|
||||
function checkTabCookieStore(context) {
|
||||
for (let index = 0; index < tabs.length; index += 1) {
|
||||
let tab = tabs[index];
|
||||
if (!tab.url.endsWith("proxyerr.html")) {
|
||||
if (tab.cookieStoreId == context[0].cookieStoreId) {
|
||||
function onProxyErrorUpdated() {
|
||||
console.warn(`(proxy) Updated tab : ` + tab);
|
||||
}
|
||||
|
||||
function onProxyError(error) {
|
||||
console.error(`(proxy) Error : ${error}`);
|
||||
}
|
||||
let createData = {
|
||||
url: "proxyerr.html",
|
||||
};
|
||||
let creating = browser.tabs.update(tab.id, createData);
|
||||
creating.then(onProxyErrorUpdated, onProxyError);
|
||||
} else {
|
||||
console.warn(
|
||||
"Not directing to proxy error page due to context mismatch"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
console.warn(
|
||||
"Not directing to proxy error page due to hostname match"
|
||||
);
|
||||
}
|
||||
function changeTabPage(tabs) {
|
||||
function checkTabCookieStore(context) {
|
||||
for (let index = 0; index < tabs.length; index += 1) {
|
||||
let tab = tabs[index];
|
||||
if (!tab.url.endsWith("proxyerr.html")) {
|
||||
if (tab.cookieStoreId == context[0].cookieStoreId) {
|
||||
function onProxyErrorUpdated() {
|
||||
console.warn(`(proxy) Updated tab : ` + tab);
|
||||
}
|
||||
|
||||
function onProxyError(error) {
|
||||
console.error(`(proxy) Error : ${error}`);
|
||||
}
|
||||
let createData = {
|
||||
url: "proxyerr.html",
|
||||
};
|
||||
let creating = browser.tabs.update(tab.id, createData);
|
||||
creating.then(onProxyErrorUpdated, onProxyError);
|
||||
} else {
|
||||
console.warn(
|
||||
"Not directing to proxy error page due to context mismatch"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
console.warn(
|
||||
"Not directing to proxy error page due to hostname match"
|
||||
);
|
||||
}
|
||||
browser.contextualIdentities
|
||||
.query({ name: titlepref })
|
||||
.then(checkTabCookieStore, changeTabErr);
|
||||
}
|
||||
}
|
||||
browser.tabs
|
||||
.query({ url: ["http://*.i2p/*"] })
|
||||
.then(changeTabPage, changeTabErr);
|
||||
browser.contextualIdentities
|
||||
.query({ name: titlepref })
|
||||
.then(checkTabCookieStore, changeTabErr);
|
||||
}
|
||||
browser.tabs
|
||||
.query({ url: ["http://*.i2p/*"] })
|
||||
.then(changeTabPage, changeTabErr);
|
||||
}
|
||||
|
||||
function update() {
|
||||
console.log("restoring proxy scheme:", proxy_scheme);
|
||||
console.log("restoring proxy host:", proxy_host);
|
||||
console.log("restoring proxy port:", proxy_port);
|
||||
console.log("restoring control host:", control_host);
|
||||
console.log("restoring control port:", control_port);
|
||||
console.log("restoring proxy scheme:", proxy_scheme);
|
||||
console.log("restoring proxy host:", proxy_host);
|
||||
console.log("restoring proxy port:", proxy_port);
|
||||
console.log("restoring control host:", control_host);
|
||||
console.log("restoring control port:", control_port);
|
||||
}
|
||||
|
||||
function updateFromStorage() {
|
||||
console.log("updating settings from storage");
|
||||
chrome.storage.local.get(function() {
|
||||
SetupSettings();
|
||||
update();
|
||||
setupProxy();
|
||||
});
|
||||
console.log("updating settings from storage");
|
||||
chrome.storage.local.get(function () {
|
||||
SetupSettings();
|
||||
update();
|
||||
setupProxy();
|
||||
});
|
||||
}
|
||||
|
||||
updateFromStorage();
|
||||
@@ -538,11 +538,11 @@ setupProxy();
|
||||
|
||||
var gettingListenerInfo = browser.runtime.getPlatformInfo();
|
||||
gettingListenerInfo.then((got) => {
|
||||
if (browser.windows != undefined) {
|
||||
browser.windows.onCreated.addListener(() => {
|
||||
chrome.storage.local.get(function() {
|
||||
setupProxy();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
if (browser.windows != undefined) {
|
||||
browser.windows.onCreated.addListener(() => {
|
||||
chrome.storage.local.get(function () {
|
||||
setupProxy();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
96
proxyinfo.js
96
proxyinfo.js
@@ -1,63 +1,63 @@
|
||||
document.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
function() {
|
||||
fetch("http://proxy.i2p").then(
|
||||
(myJson) => {
|
||||
console.warn("(proxyinfo)", myJson);
|
||||
contentUpdateById("proxy-check", "proxySuccessStatus");
|
||||
let readyness = document.querySelectorAll(".readyness");
|
||||
if (readyness !== null) {
|
||||
unhide(readyness);
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.error("(proxyinfo)", error);
|
||||
contentUpdateById("proxy-check", "proxyFailedStatus");
|
||||
let readyness = document.querySelectorAll(".readyness");
|
||||
if (readyness !== null) {
|
||||
hide(readyness);
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
false
|
||||
"DOMContentLoaded",
|
||||
function () {
|
||||
fetch("http://proxy.i2p").then(
|
||||
(myJson) => {
|
||||
console.warn("(proxyinfo)", myJson);
|
||||
contentUpdateById("proxy-check", "proxySuccessStatus");
|
||||
let readyness = document.querySelectorAll(".readyness");
|
||||
if (readyness !== null) {
|
||||
unhide(readyness);
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.error("(proxyinfo)", error);
|
||||
contentUpdateById("proxy-check", "proxyFailedStatus");
|
||||
let readyness = document.querySelectorAll(".readyness");
|
||||
if (readyness !== null) {
|
||||
hide(readyness);
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
function hide(elements) {
|
||||
elements = elements.length ? elements : [elements];
|
||||
for (var index = 0; index < elements.length; index++) {
|
||||
if (elements[index].style !== undefined) {
|
||||
elements[index].style.display = "none";
|
||||
}
|
||||
elements = elements.length ? elements : [elements];
|
||||
for (var index = 0; index < elements.length; index++) {
|
||||
if (elements[index].style !== undefined) {
|
||||
elements[index].style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function unhide(elements) {
|
||||
elements = elements.length ? elements : [elements];
|
||||
for (var index = 0; index < elements.length; index++) {
|
||||
if (elements[index].style !== undefined) {
|
||||
elements[index].style.display = "inline-block";
|
||||
}
|
||||
elements = elements.length ? elements : [elements];
|
||||
for (var index = 0; index < elements.length; index++) {
|
||||
if (elements[index].style !== undefined) {
|
||||
elements[index].style.display = "inline-block";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Don't hard-code this.
|
||||
fetch("http://127.0.0.1:7657/themes/console/light/images/i2plogo.png")
|
||||
.then((myJson) => {
|
||||
var consoleLinks = document.querySelectorAll(".application-info");
|
||||
unhide(consoleLinks);
|
||||
})
|
||||
.catch((error) => {
|
||||
var consoleLinks = document.querySelectorAll(".application-info");
|
||||
hide(consoleLinks);
|
||||
});
|
||||
.then((myJson) => {
|
||||
var consoleLinks = document.querySelectorAll(".application-info");
|
||||
unhide(consoleLinks);
|
||||
})
|
||||
.catch((error) => {
|
||||
var consoleLinks = document.querySelectorAll(".application-info");
|
||||
hide(consoleLinks);
|
||||
});
|
||||
|
||||
fetch("http://127.0.0.1:7657/jsonrpc/")
|
||||
.then((myJson) => {
|
||||
var toopieLinks = document.querySelectorAll(".window-visit-toopie");
|
||||
unhide(toopieLinks);
|
||||
})
|
||||
.catch((error) => {
|
||||
var toopieLinks = document.querySelectorAll(".window-visit-toopie");
|
||||
hide(toopieLinks);
|
||||
});
|
||||
.then((myJson) => {
|
||||
var toopieLinks = document.querySelectorAll(".window-visit-toopie");
|
||||
unhide(toopieLinks);
|
||||
})
|
||||
.catch((error) => {
|
||||
var toopieLinks = document.querySelectorAll(".window-visit-toopie");
|
||||
hide(toopieLinks);
|
||||
});
|
||||
|
Reference in New Issue
Block a user