get rid of old scrub version
This commit is contained in:
55
bookmarks.js
55
bookmarks.js
@@ -1,6 +1,6 @@
|
||||
function bookmarksSetup() {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
gettingInfo.then(got => {
|
||||
if (got.os != "android") {
|
||||
function bookmarks(bookmarkToolbar) {
|
||||
console.log("(bookmarks)", bookmarkToolbar);
|
||||
@@ -13,14 +13,14 @@ function bookmarksSetup() {
|
||||
let createRhizomeBookmark = browser.bookmarks.create({
|
||||
url: "about:I2p",
|
||||
title: "I2P Extension Home Page",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createRhizomeBookmark.then(onCreated);
|
||||
} else {
|
||||
let createBookmark = browser.bookmarks.create({
|
||||
url: browser.runtime.getURL("home.html"),
|
||||
title: "I2P Extension Home Page",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createBookmark.then(onCreated);
|
||||
}
|
||||
@@ -41,15 +41,19 @@ function bookmarksSetup() {
|
||||
let createBookmark = browser.bookmarks.create({
|
||||
url: "http://localhost:7657/i2psnark",
|
||||
title: "Bittorrent",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createBookmark.then(onCreated);
|
||||
} else {
|
||||
let createRhizomeBookmark = browser.bookmarks.create({
|
||||
url:
|
||||
"http://" + control_host + ":" + control_port + "/i2psnark",
|
||||
"http://" +
|
||||
control_host() +
|
||||
":" +
|
||||
control_port() +
|
||||
"/i2psnark",
|
||||
title: "Bittorrent",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createRhizomeBookmark.then(onCreated);
|
||||
}
|
||||
@@ -69,14 +73,15 @@ function bookmarksSetup() {
|
||||
let createBookmark = browser.bookmarks.create({
|
||||
url: "http://localhost:7657/home",
|
||||
title: "I2P Console",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createBookmark.then(onCreated);
|
||||
} else {
|
||||
let createRhizomeBookmark = browser.bookmarks.create({
|
||||
url: "http://" + control_host + ":" + control_port + "/home",
|
||||
url:
|
||||
"http://" + control_host() + ":" + control_port() + "/home",
|
||||
title: "I2P Console",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createRhizomeBookmark.then(onCreated);
|
||||
}
|
||||
@@ -96,15 +101,19 @@ function bookmarksSetup() {
|
||||
let createBookmark = browser.bookmarks.create({
|
||||
url: "http://localhost:7657/webmail",
|
||||
title: "Web Mail",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createBookmark.then(onCreated);
|
||||
} else {
|
||||
let createRhizomeBookmark = browser.bookmarks.create({
|
||||
url:
|
||||
"http://" + control_host + ":" + control_port + "/webmail",
|
||||
"http://" +
|
||||
control_host() +
|
||||
":" +
|
||||
control_port() +
|
||||
"/webmail",
|
||||
title: "Web Mail",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createRhizomeBookmark.then(onCreated);
|
||||
}
|
||||
@@ -125,19 +134,19 @@ function bookmarksSetup() {
|
||||
var createBookmark = browser.bookmarks.create({
|
||||
url: "http://localhost:7657/i2ptunnel",
|
||||
title: "Hidden Services Manager",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createBookmark.then(onCreated);
|
||||
} else {
|
||||
var createRhizomeBookmark = browser.bookmarks.create({
|
||||
url:
|
||||
"http://" +
|
||||
control_host +
|
||||
control_host() +
|
||||
":" +
|
||||
control_port +
|
||||
control_port() +
|
||||
"/i2ptunnel",
|
||||
title: "Hidden Services Manager",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createRhizomeBookmark.then(onCreated);
|
||||
}
|
||||
@@ -159,34 +168,34 @@ function bookmarksSetup() {
|
||||
}
|
||||
|
||||
var b0 = browser.bookmarks.search({
|
||||
title: "I2P Extension Home Page",
|
||||
title: "I2P Extension Home Page"
|
||||
});
|
||||
b0.then(bookHome, onRejected);
|
||||
|
||||
var b1 = browser.bookmarks.search({
|
||||
title: "Bittorrent",
|
||||
title: "Bittorrent"
|
||||
});
|
||||
b1.then(bookTorrent, onRejected);
|
||||
|
||||
var b2 = browser.bookmarks.search({
|
||||
title: "Hidden Services Manager",
|
||||
title: "Hidden Services Manager"
|
||||
});
|
||||
b2.then(bookI2PTunnel, onRejected);
|
||||
|
||||
var b3 = browser.bookmarks.search({
|
||||
title: "Web Mail",
|
||||
title: "Web Mail"
|
||||
});
|
||||
b3.then(bookMail, onRejected);
|
||||
|
||||
var b4 = browser.bookmarks.search({
|
||||
title: "I2P Console",
|
||||
title: "I2P Console"
|
||||
});
|
||||
b4.then(bookConsole, onRejected);
|
||||
defaultSettings["bookmarks_state"] = true;
|
||||
}
|
||||
|
||||
var bt = browser.bookmarks.search({
|
||||
query: "Toolbar",
|
||||
query: "Toolbar"
|
||||
});
|
||||
|
||||
function toolDir(bookmarkToolbar) {
|
||||
@@ -202,7 +211,7 @@ function bookmarksSetup() {
|
||||
if (ibbt[0] == null) {
|
||||
let createBookmark = browser.bookmarks.create({
|
||||
title: "I2P Toolbar",
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
parentId: bookmarkToolbar[0].id
|
||||
});
|
||||
createBookmark.then(onToolbarCreated);
|
||||
}
|
||||
|
69
config.js
69
config.js
@@ -1,18 +1,61 @@
|
||||
var proxy_scheme = "HTTP";
|
||||
var proxy_host = "127.0.0.1";
|
||||
var proxy_port = "4444";
|
||||
function proxy_scheme() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageProxyScheme();
|
||||
}
|
||||
function proxy_host() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageHost();
|
||||
}
|
||||
function proxy_port() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStoragePort();
|
||||
}
|
||||
|
||||
var control_host = "127.0.0.1";
|
||||
var control_port = "7657";
|
||||
function control_host() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageControlHost();
|
||||
}
|
||||
function control_port() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageControlPort();
|
||||
}
|
||||
|
||||
var rpc_host = "127.0.0.1";
|
||||
var rpc_port = "7657";
|
||||
var rpc_path = "jsonrpc";
|
||||
var rpc_pass = "itoopie";
|
||||
function rpc_host() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageRPCHost();
|
||||
}
|
||||
function rpc_port() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageRPCPort();
|
||||
}
|
||||
function rpc_path() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
getFromStorageRPCPath();
|
||||
}
|
||||
function rpc_pass() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageRPCPass();
|
||||
}
|
||||
|
||||
var bt_rpc_host = "127.0.0.1";
|
||||
var bt_rpc_port = "7657";
|
||||
var bt_rpc_path = "transmission/rpc";
|
||||
var bt_rpc_pass = "transmission";
|
||||
function bt_rpc_host() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageBTRPCHost();
|
||||
}
|
||||
function bt_rpc_port() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageBTRPCPort();
|
||||
}
|
||||
function bt_rpc_path() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageBTRPCPath();
|
||||
}
|
||||
function bt_rpc_pass() {
|
||||
console.info("(config)Got i2p:", getFuncName());
|
||||
return getFromStorageBTRPCPass();
|
||||
}
|
||||
|
||||
function getFuncName() {
|
||||
return getFuncName.caller.name;
|
||||
}
|
||||
|
||||
var disable_history = false;
|
||||
|
96
handler.js
96
handler.js
@@ -1,99 +1,3 @@
|
||||
function routerHost(url) {
|
||||
// console.log("(urlcheck) HANDLER URL CHECK");
|
||||
let hostname = "";
|
||||
let path = "";
|
||||
|
||||
function pathcheck(str) {
|
||||
// console.log("(urlcheck) HANDLER PATH CHECK", 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";
|
||||
}
|
||||
}
|
||||
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) {
|
||||
//console.log("(hostcheck) router console found on configured ports");
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "localhost" + ":" + control_port) {
|
||||
//console.log("(hostcheck) router console found on configured ports");
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "127.0.0.1" + ":" + control_port) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "localhost" + ":" + 7667) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
if (hostname === "127.0.0.1" + ":" + 7667) {
|
||||
return pathcheck(path);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function identifyProtocolHandler(url) {
|
||||
//console.log("looking for handler-able requests")
|
||||
if (routerHost(url)) {
|
||||
if (url.includes(encodeURIComponent("ext+rc:"))) {
|
||||
return url.replace(encodeURIComponent("ext+rc:"), "");
|
||||
} else if (url.includes("ext+rc:")) {
|
||||
return url.replace("ext+rc:", "");
|
||||
}
|
||||
} else if (url.includes("ext+rc:")) {
|
||||
return url;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function trimHost(url) {
|
||||
let hostname = "";
|
||||
let prefix = "";
|
||||
|
110
host.js
110
host.js
@@ -1,63 +1,40 @@
|
||||
function proxyHost(requestDetails) {
|
||||
if (requestDetails.originUrl != browser.runtime.getURL("window.html")) {
|
||||
} else if (requestDetails.originUrl != browser.runtime.getURL("home.html")) {
|
||||
} else {
|
||||
const originUrl = requestDetails.originUrl;
|
||||
const isWindowOrHomeUrl =
|
||||
originUrl !== browser.runtime.getURL("window.html") &&
|
||||
originUrl !== browser.runtime.getURL("home.html");
|
||||
|
||||
if (isWindowOrHomeUrl) {
|
||||
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;
|
||||
}
|
||||
const urlParts = requestDetails.url.split("/");
|
||||
const hostname = urlParts[2].indexOf("://") > -1 ? urlParts[2] : urlParts[0];
|
||||
|
||||
console.warn("(host) requestDetails", requestDetails.url);
|
||||
if (
|
||||
hostname == "c6lilt4cr5x7jifxridpkesf2zgfwqfchtp6laihr4pdqomq25iq.b32.i2p"
|
||||
hostname === "proxy.i2p" ||
|
||||
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) {
|
||||
function isLocalHost(url) {
|
||||
// function getLocalhostUrlType(url) {
|
||||
const urlPath = url.split("/")[2].split(":")[0];
|
||||
if (urlPath === "127.0.0.1" || urlPath === "localhost") {
|
||||
if (url.includes(":8084")) {
|
||||
return "blog";
|
||||
}
|
||||
if (url.indexOf(":7669") != -1) {
|
||||
if (url.includes(":7669")) {
|
||||
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) {
|
||||
if (url.includes(":7695")) {
|
||||
return "tor";
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -182,42 +159,45 @@ function getPathApplication(str, url) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function routerHost(url) {
|
||||
// console.log("(urlcheck) HOST URL CHECK");
|
||||
function isRouterHost(url) {
|
||||
let hostname = "";
|
||||
let path = "";
|
||||
|
||||
if (url.indexOf("://") > -1) {
|
||||
hostname = url.split("/")[2];
|
||||
let prefix = url.substr(0, url.indexOf("://") + 3);
|
||||
path = url.replace(prefix + hostname + "/", "");
|
||||
const protocol = url.substr(0, url.indexOf("://") + 3);
|
||||
path = url.replace(protocol + hostname + "/", "");
|
||||
} else if (identifyProtocolHandler(url)) {
|
||||
let newurl = identifyProtocolHandler(url);
|
||||
return routerHost(newurl);
|
||||
const newUrl = identifyProtocolHandler(url);
|
||||
return isRouterHost(newUrl);
|
||||
} else {
|
||||
hostname = url.split("/")[0];
|
||||
path = url.replace(hostname + "/", "");
|
||||
}
|
||||
if (hostname === control_host + ":" + control_port) {
|
||||
|
||||
const localHosts = ["localhost", "127.0.0.1"];
|
||||
const controlHost = control_host();
|
||||
const controlPort = control_port();
|
||||
const isLocalHost = localHosts.includes(hostname.split(":")[0]);
|
||||
|
||||
if (hostname === `${controlHost}:${controlPort}` || isLocalHost) {
|
||||
return getPathApplication(path, url);
|
||||
}
|
||||
if (hostname === "localhost:" + control_port) {
|
||||
return getPathApplication(path, url);
|
||||
}
|
||||
if (hostname === "127.0.0.1:" + control_port) {
|
||||
return getPathApplication(path, url);
|
||||
}
|
||||
if (hostname === "localhost" + ":" + 7070) {
|
||||
return getPathApplication(path, url);
|
||||
}
|
||||
if (hostname === "127.0.0.1" + ":" + 7070) {
|
||||
return getPathApplication(path, url);
|
||||
}
|
||||
if (hostname === "localhost" + ":" + 7667) {
|
||||
return getPathApplication(path, url);
|
||||
}
|
||||
if (hostname === "127.0.0.1" + ":" + 7667) {
|
||||
return getPathApplication(path, url);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function identifyProtocolHandler(url) {
|
||||
//console.log("looking for handler-able requests")
|
||||
if (isRouterHost(url)) {
|
||||
if (url.includes(encodeURIComponent("ext+rc:"))) {
|
||||
return url.replace(encodeURIComponent("ext+rc:"), "");
|
||||
} else if (url.includes("ext+rc:")) {
|
||||
return url.replace("ext+rc:", "");
|
||||
}
|
||||
} else if (url.includes("ext+rc:")) {
|
||||
return url;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
4
info.js
4
info.js
@@ -347,9 +347,7 @@ function goURL() {
|
||||
}
|
||||
|
||||
function routerAddr() {
|
||||
if (!control_host) var control_host = "127.0.0.1";
|
||||
if (!control_port) var control_port = "7657";
|
||||
return control_host + ":" + control_port;
|
||||
return control_host() + ":" + control_port();
|
||||
}
|
||||
|
||||
function goConsole() {
|
||||
|
@@ -70,6 +70,7 @@
|
||||
"background": {
|
||||
"persistent": false,
|
||||
"scripts": [
|
||||
"options/options.js",
|
||||
"config.js",
|
||||
"torrent/common.js",
|
||||
"torrent/background.js",
|
||||
@@ -82,7 +83,7 @@
|
||||
"proxy.js",
|
||||
"info.js",
|
||||
"home.js",
|
||||
"scrub-2.js",
|
||||
"scrub.js",
|
||||
"bookmarks.js"
|
||||
]
|
||||
},
|
||||
|
@@ -6,37 +6,49 @@ function SetBookButton() {
|
||||
|
||||
function SetHostText() {
|
||||
var hostid = document.getElementById("hostText");
|
||||
hostid.textContent = chrome.i18n.getMessage("hostText");
|
||||
if (hostid != undefined) {
|
||||
hostid.textContent = chrome.i18n.getMessage("hostText");
|
||||
}
|
||||
}
|
||||
|
||||
function SetPortText() {
|
||||
var portid = document.getElementById("portText");
|
||||
portid.textContent = chrome.i18n.getMessage("portText");
|
||||
if (portid != undefined) {
|
||||
portid.textContent = chrome.i18n.getMessage("portText");
|
||||
}
|
||||
}
|
||||
|
||||
function SetPortHelpText() {
|
||||
var portid = document.getElementById("proxyHelpText");
|
||||
portid.textContent = chrome.i18n.getMessage("proxyHelpText");
|
||||
if (portid != undefined) {
|
||||
portid.textContent = chrome.i18n.getMessage("proxyHelpText");
|
||||
}
|
||||
}
|
||||
|
||||
function SetControlHostText() {
|
||||
var controlhostid = document.getElementById("controlHostText");
|
||||
controlhostid.textContent = chrome.i18n.getMessage("controlHostText");
|
||||
if (controlhostid != undefined) {
|
||||
controlhostid.textContent = chrome.i18n.getMessage("controlHostText");
|
||||
}
|
||||
}
|
||||
|
||||
function SetControlPortText() {
|
||||
var controlportid = document.getElementById("controlPortText");
|
||||
controlportid.textContent = chrome.i18n.getMessage("controlPortText");
|
||||
if (controlportid != undefined) {
|
||||
controlportid.textContent = chrome.i18n.getMessage("controlPortText");
|
||||
}
|
||||
}
|
||||
|
||||
function SetControlHelpText() {
|
||||
var portid = document.getElementById("controlHelpText");
|
||||
portid.textContent = chrome.i18n.getMessage("controlHelpText");
|
||||
if (portid != undefined) {
|
||||
portid.textContent = chrome.i18n.getMessage("controlHelpText");
|
||||
}
|
||||
}
|
||||
|
||||
function getBoolFromStorage(key) {
|
||||
let key_state = localStorage.getItem(key);
|
||||
console.log("(options) Got i2p settings key state", key, key_state);
|
||||
console.info("(options) Got i2p settings key state", key, key_state);
|
||||
if (key_state == undefined) {
|
||||
return false;
|
||||
}
|
||||
@@ -51,7 +63,7 @@ function getBoolFromStorage(key) {
|
||||
|
||||
function getStringFromStorage(key, valdef) {
|
||||
let key_state = localStorage.getItem(key);
|
||||
console.log("(options) Got i2p settings key state", key, key_state);
|
||||
console.info("(options) Got i2p settings key state", key, key_state);
|
||||
if (key_state == undefined) {
|
||||
return valdef;
|
||||
}
|
||||
@@ -60,7 +72,7 @@ function getStringFromStorage(key, valdef) {
|
||||
|
||||
function getFromStorageBookmarksCreated() {
|
||||
let bookmarks_state = getBoolFromStorage("bookmarks_created");
|
||||
console.log("(options)Got i2p bookmarks state:", bookmarks_state);
|
||||
console.info("(options)Got i2p bookmarks state:", bookmarks_state);
|
||||
return bookmarks_state;
|
||||
}
|
||||
|
||||
@@ -81,7 +93,7 @@ function getFromHTMLValueBookmarksCreated() {
|
||||
|
||||
function getFromStorageProxyScheme() {
|
||||
let proxy_scheme = getStringFromStorage("proxy_scheme", "http");
|
||||
console.log("(options)Got i2p proxy scheme:", proxy_scheme);
|
||||
console.info("(options)Got i2p proxy scheme:", proxy_scheme);
|
||||
return proxy_scheme;
|
||||
}
|
||||
|
||||
@@ -105,8 +117,8 @@ function getFromHTMLValueScheme() {
|
||||
}
|
||||
|
||||
function getFromStorageHost() {
|
||||
let proxy_host = getStringFromStorage("proxy_host","127.0.0.1");
|
||||
console.log("(options)Got i2p proxy host:", proxy_host);
|
||||
let proxy_host = getStringFromStorage("proxy_host", "127.0.0.1");
|
||||
console.info("(options)Got i2p proxy host:", proxy_host);
|
||||
return proxy_host;
|
||||
}
|
||||
|
||||
@@ -121,7 +133,7 @@ function getFromHTMLValueHost() {
|
||||
|
||||
function getFromStoragePort() {
|
||||
let proxy_port = getStringFromStorage("proxy_port", 4444);
|
||||
console.log("(options)Got i2p proxy port:", proxy_port);
|
||||
console.info("(options)Got i2p proxy port:", proxy_port);
|
||||
return proxy_port;
|
||||
}
|
||||
|
||||
@@ -135,8 +147,8 @@ function getFromHTMLValuePort() {
|
||||
}
|
||||
|
||||
function getFromStorageControlHost() {
|
||||
let control_host = getStringFromStorage("control_host");
|
||||
console.log("(options)Got i2p control host:", control_host);
|
||||
let control_host = getStringFromStorage("control_host", "127.0.0.1");
|
||||
console.info("(options)Got i2p control host:", control_host);
|
||||
return control_host;
|
||||
}
|
||||
|
||||
@@ -150,8 +162,8 @@ function getFromHTMLValueControlHost() {
|
||||
}
|
||||
|
||||
function getFromStorageControlPort() {
|
||||
let control_port = getStringFromStorage("control_port");
|
||||
console.log("(options)Got i2p control port:", control_port);
|
||||
let control_port = getStringFromStorage("control_port", 7657);
|
||||
console.info("(options)Got i2p control port:", control_port);
|
||||
return control_port;
|
||||
}
|
||||
|
||||
@@ -165,8 +177,8 @@ function getFromHTMLValueControlPort() {
|
||||
}
|
||||
|
||||
function getFromStorageRPCHost() {
|
||||
let rpc_host = getStringFromStorage("rpc_host");
|
||||
console.log("(options)Got i2pcontrol rpc host:", rpc_host);
|
||||
let rpc_host = getStringFromStorage("rpc_host", "127.0.0.1");
|
||||
console.info("(options)Got i2pcontrol rpc host:", rpc_host);
|
||||
return rpc_host;
|
||||
}
|
||||
|
||||
@@ -180,8 +192,8 @@ function getFromHTMLValueRPCHost() {
|
||||
}
|
||||
|
||||
function getFromStorageRPCPort() {
|
||||
let rpc_port = getStringFromStorage("rpc_port");
|
||||
console.log("(options)Got i2pcontrol rpc port:", rpc_port);
|
||||
let rpc_port = getStringFromStorage("rpc_port", "7657");
|
||||
console.info("(options)Got i2pcontrol rpc port:", rpc_port);
|
||||
return rpc_port;
|
||||
}
|
||||
|
||||
@@ -195,8 +207,8 @@ function getFromHTMLValueRPCPort() {
|
||||
}
|
||||
|
||||
function getFromStorageRPCPath() {
|
||||
let rpc_path = getStringFromStorage("rpc_path");
|
||||
console.log("(options)Got i2pcontrol rpc path:", rpc_path);
|
||||
let rpc_path = getStringFromStorage("rpc_path", "jsonrpc");
|
||||
console.info("(options)Got i2pcontrol rpc path:", rpc_path);
|
||||
return rpc_path;
|
||||
}
|
||||
|
||||
@@ -210,8 +222,8 @@ function getFromHTMLValueRPCPath() {
|
||||
}
|
||||
|
||||
function getFromStorageRPCPass() {
|
||||
let rpc_pass = getStringFromStorage("rpc_pass");
|
||||
console.log("(options)Got i2pcontrol rpc password:", rpc_pass);
|
||||
let rpc_pass = getStringFromStorage("rpc_pass", "itoopie");
|
||||
console.info("(options)Got i2pcontrol rpc password:", rpc_pass);
|
||||
return rpc_pass;
|
||||
}
|
||||
|
||||
@@ -225,8 +237,8 @@ function getFromHTMLValueRPCPass() {
|
||||
}
|
||||
|
||||
function getFromStorageBTRPCHost() {
|
||||
let bt_rpc_host = getStringFromStorage("bt_rpc_host");
|
||||
console.log("(options)Got torrent rpc host:", bt_rpc_host);
|
||||
let bt_rpc_host = getStringFromStorage("bt_rpc_host", "127.0.0.1");
|
||||
console.info("(options)Got torrent rpc host:", bt_rpc_host);
|
||||
return bt_rpc_host;
|
||||
}
|
||||
|
||||
@@ -240,8 +252,8 @@ function getFromHTMLValueBTRPCHost() {
|
||||
}
|
||||
|
||||
function getFromStorageBTRPCPort() {
|
||||
let bt_rpc_port = getStringFromStorage("bt_rpc_port");
|
||||
console.log("(options)Got torrent rpc port:", bt_rpc_port);
|
||||
let bt_rpc_port = getStringFromStorage("bt_rpc_port", "7657");
|
||||
console.info("(options)Got torrent rpc port:", bt_rpc_port);
|
||||
return bt_rpc_port;
|
||||
}
|
||||
|
||||
@@ -255,8 +267,8 @@ function getFromHTMLValueBTRPCPort() {
|
||||
}
|
||||
|
||||
function getFromStorageBTRPCPath() {
|
||||
let bt_rpc_path = getStringFromStorage("bt_rpc_path");
|
||||
console.log("(options)Got torrent rpc path:", bt_rpc_path);
|
||||
let bt_rpc_path = getStringFromStorage("bt_rpc_path", "transmission/rpc");
|
||||
console.info("(options)Got torrent rpc path:", bt_rpc_path);
|
||||
return bt_rpc_path;
|
||||
}
|
||||
|
||||
@@ -270,8 +282,8 @@ function getFromHTMLValueBTRPCPath() {
|
||||
}
|
||||
|
||||
function getFromStorageBTRPCPass() {
|
||||
let bt_rpc_pass = getStringFromStorage("bt_rpc_pass");
|
||||
console.log("(options)Got torrent rpc password:", bt_rpc_pass);
|
||||
let bt_rpc_pass = getStringFromStorage("bt_rpc_pass", "itoopie");
|
||||
console.info("(options)Got torrent rpc password:", bt_rpc_pass);
|
||||
return bt_rpc_pass;
|
||||
}
|
||||
|
||||
@@ -297,32 +309,20 @@ function checkStoredSettings(storedSettings) {
|
||||
settings.bookmarks_state = storedSettings.bookmarks_state || false;
|
||||
settings.proxy_scheme = storedSettings.proxy_scheme || "http";
|
||||
settings.proxy_host =
|
||||
storedSettings.proxy_host || (host === ""
|
||||
? "127.0.0.1"
|
||||
: host);
|
||||
storedSettings.proxy_host || (host === "" ? "127.0.0.1" : host);
|
||||
settings.proxy_port =
|
||||
storedSettings.proxy_port ||
|
||||
(port === undefined
|
||||
? 4444
|
||||
: port === 7644
|
||||
? port
|
||||
: 4444);
|
||||
(port === undefined ? 4444 : port === 7644 ? port : 4444);
|
||||
settings.control_host =
|
||||
storedSettings.control_host || (host === ""
|
||||
? "127.0.0.1"
|
||||
: host);
|
||||
storedSettings.control_host || (host === "" ? "127.0.0.1" : host);
|
||||
settings.control_port = storedSettings.control_port || 7657;
|
||||
settings.rpc_host =
|
||||
storedSettings.rpc_host || (host === ""
|
||||
? "127.0.0.1"
|
||||
: host);
|
||||
storedSettings.rpc_host || (host === "" ? "127.0.0.1" : host);
|
||||
settings.rpc_port = storedSettings.rpc_port || 7657;
|
||||
settings.rpc_path = storedSettings.rpc_path || "jsonrpc";
|
||||
settings.rpc_pass = storedSettings.rpc_pass || "itoopie";
|
||||
settings.bt_rpc_host =
|
||||
storedSettings.bt_rpc_host || (host === ""
|
||||
? "127.0.0.1"
|
||||
: host);
|
||||
storedSettings.bt_rpc_host || (host === "" ? "127.0.0.1" : host);
|
||||
settings.bt_rpc_port = storedSettings.bt_rpc_port || 7657;
|
||||
settings.bt_rpc_path = storedSettings.bt_rpc_path || "transmission/";
|
||||
settings.bt_rpc_pass = storedSettings.bt_rpc_pass || "transmission";
|
||||
@@ -333,7 +333,7 @@ function checkStoredSettings(storedSettings) {
|
||||
return settings;
|
||||
}
|
||||
const gettingInfo = browser.proxy.settings.get({});
|
||||
return gettingInfo.then(gotProxyInfo).catch(error => {
|
||||
return gettingInfo.then(gotProxyInfo).catch((error) => {
|
||||
console.error(error);
|
||||
throw new Error("Error in checkStoredSettings");
|
||||
});
|
||||
@@ -354,20 +354,15 @@ function checkAndroidStoredSettings(settings) {
|
||||
btRpcHost: "127.0.0.1",
|
||||
btRpcPort: 7657,
|
||||
btRpcPath: "transmission/rpc",
|
||||
btRpcPass: "transmission"
|
||||
btRpcPass: "transmission",
|
||||
};
|
||||
|
||||
const mergedSettings = { ...defaults,
|
||||
...settings };
|
||||
const mergedSettings = { ...defaults, ...settings };
|
||||
const { proxyHost: host, proxyPort: port } = mergedSettings;
|
||||
|
||||
mergedSettings.proxyHost = host || defaults.proxyHost;
|
||||
mergedSettings.proxyPort =
|
||||
port === undefined
|
||||
? 4444
|
||||
: port === 7644
|
||||
? port
|
||||
: 4444;
|
||||
port === undefined ? 4444 : port === 7644 ? port : 4444;
|
||||
|
||||
console.log("Merged settings:", mergedSettings);
|
||||
|
||||
@@ -392,7 +387,12 @@ function storeSettings() {
|
||||
storableSettings["bt_rpc_path"] = getFromHTMLValueBTRPCPath();
|
||||
storableSettings["bt_rpc_pass"] = getFromHTMLValueBTRPCPass();
|
||||
storableSettings["base_url"] =
|
||||
"http://" + storableSettings["rpc_host"] + ":" + storableSettings["bt_rpc_port"] + "/" + storableSettings["bt_rpc_path"];
|
||||
"http://" +
|
||||
storableSettings["rpc_host"] +
|
||||
":" +
|
||||
storableSettings["bt_rpc_port"] +
|
||||
"/" +
|
||||
storableSettings["bt_rpc_path"];
|
||||
console.log("storing", storableSettings);
|
||||
chrome.storage.local.set(storableSettings);
|
||||
}
|
||||
@@ -423,13 +423,13 @@ function updateUI(restoredSettings) {
|
||||
//console.log("(options)showing proxy port:", portitem.value);
|
||||
|
||||
const controlhostitem = document.getElementById("controlhost");
|
||||
if (controlhostitem == undefined) {
|
||||
if (controlhostitem != undefined) {
|
||||
controlhostitem.value = restoredSettings.control_host;
|
||||
}
|
||||
//console.log("(options)showing control host:", controlhostitem.value);
|
||||
|
||||
const controlportitem = document.getElementById("controlport");
|
||||
if (controlportitem == undefined) {
|
||||
if (controlportitem != undefined) {
|
||||
controlportitem.value = restoredSettings.control_port;
|
||||
}
|
||||
//console.log("(options)showing control port:", controlportitem.value);
|
||||
@@ -500,15 +500,17 @@ gettingInfo.then(function (gotPlatform) {
|
||||
if (gotPlatform.os == "android") {
|
||||
browser.storage.local.get(function (gotSettings) {
|
||||
checkAndroidStoredSettings(gotSettings);
|
||||
updateUI(gotSettings);
|
||||
updateUI(gotSettings, onError);
|
||||
});
|
||||
} else {
|
||||
chrome.storage.local.get(function (gotSettings) {
|
||||
let settings = checkStoredSettings(gotSettings);
|
||||
settings.then(updateUI);
|
||||
settings.then(updateUI, onError);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const saveButton = document.querySelector("#save-button");
|
||||
saveButton.addEventListener("click", storeSettings);
|
||||
if (saveButton != undefined) {
|
||||
saveButton.addEventListener("click", storeSettings);
|
||||
}
|
||||
|
273
proxy.js
273
proxy.js
@@ -14,14 +14,14 @@ 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.");
|
||||
|
||||
@@ -32,9 +32,9 @@ function shouldProxyRequest(requestInfo) {
|
||||
var handleContextProxyRequest = async function (requestDetails) {
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
console.warn("(proxy) is proxy check");
|
||||
return proxy;
|
||||
@@ -43,9 +43,9 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
function ircProxy() {
|
||||
if (!requestDetails.url.includes("7669")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
@@ -60,9 +60,9 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
function torProxy() {
|
||||
if (!requestDetails.url.includes("7695")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
@@ -75,9 +75,9 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
function blogProxy() {
|
||||
if (!requestDetails.url.includes("8084")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
@@ -100,14 +100,14 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
function mainProxy() {
|
||||
console.log("(proxy) mainproxy 0");
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
let url = new URL(requestDetails.url);
|
||||
if (
|
||||
requestDetails.url.startsWith(
|
||||
"http://" + getHost() + ":" + getConsolePort() + "/i2psnark/"
|
||||
"http://" + proxy_host() + ":" + control_port() + "/i2psnark/"
|
||||
)
|
||||
) {
|
||||
//+url.host)) {
|
||||
@@ -118,14 +118,14 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
}
|
||||
|
||||
function routerProxy() {
|
||||
if (routerHost(requestDetails.url)) {
|
||||
if (isRouterHost(requestDetails.url)) {
|
||||
proxy = null;
|
||||
return proxy;
|
||||
} else if (!routerHost(requestDetails.url)) {
|
||||
} else if (!isRouterHost(requestDetails.url)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
@@ -133,9 +133,9 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
try {
|
||||
var handleProxyRequest = function (context) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
|
||||
if (context == "firefox-default" || context == "firefox-private") {
|
||||
@@ -178,8 +178,8 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
return proxy;
|
||||
}
|
||||
} else {
|
||||
if (!routerHost(requestDetails.url)) {
|
||||
if (localHost(requestDetails.url)) {
|
||||
if (!isRouterHost(requestDetails.url)) {
|
||||
if (getLocalhostUrlType(requestDetails.url)) {
|
||||
if (requestDetails.url.includes(":7669")) {
|
||||
proxy = null;
|
||||
} else if (requestDetails.url.includes(":7662")) {
|
||||
@@ -196,20 +196,18 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
}
|
||||
if (i2pHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
} else if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
} else {
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
};
|
||||
} else {
|
||||
proxy = null;
|
||||
}
|
||||
proxy = null;
|
||||
}
|
||||
if (requestDetails.url.includes("rpc")) {
|
||||
console.log("(proxy for rpc url)", rpc);
|
||||
@@ -238,17 +236,17 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
};
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
if (requestDetails.originUrl == browser.runtime.getURL("security.html")) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
@@ -266,9 +264,9 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
}
|
||||
if (proxyHost(requestDetails)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
return proxy;
|
||||
} else if (i2pHost(requestDetails)) {
|
||||
@@ -292,9 +290,9 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
return proxy;*/
|
||||
} else {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
type: proxy_scheme(),
|
||||
host: proxy_host(),
|
||||
port: proxy_port()
|
||||
};
|
||||
//console.log('(proxy for rpc url)', rpc);
|
||||
return proxy;
|
||||
@@ -306,159 +304,12 @@ var handleContextProxyRequest = async function (requestDetails) {
|
||||
|
||||
function SetupSettings() {
|
||||
console.log("Initialising Settings");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
console.log("Initialising Host", storedSettings.proxy_host);
|
||||
setupProxy();
|
||||
}
|
||||
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);
|
||||
|
||||
//
|
||||
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
|
||||
);
|
||||
|
||||
//
|
||||
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);
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
function getHost() {
|
||||
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";
|
||||
}
|
||||
}
|
||||
return proxy_port;
|
||||
}
|
||||
|
||||
function getConsolePort() {
|
||||
if (control_port == undefined) {
|
||||
var scheme = getScheme();
|
||||
if (scheme == "socks") {
|
||||
proxy_port = "7657";
|
||||
} else {
|
||||
control_port = "7657";
|
||||
}
|
||||
}
|
||||
return control_port;
|
||||
}
|
||||
|
||||
function setupProxy() {
|
||||
console.log("Setting up Firefox WebExtension proxy");
|
||||
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
|
||||
urls: ["<all_urls>"],
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy");
|
||||
browser.proxy.onError.addListener(handleContextProxyError);
|
||||
@@ -469,7 +320,7 @@ function handleContextProxyError(err) {
|
||||
console.error(`(proxy) Error : ${error}`);
|
||||
}
|
||||
console.warn("(proxy) Error:", err);
|
||||
if ((err.message = 'ProxyInfoData: Invalid proxy server type: "undefined"')) {
|
||||
if (err.message = "ProxyInfoData: Invalid proxy server type: \"undefined\"") {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -480,14 +331,14 @@ function handleContextProxyError(err) {
|
||||
if (!tab.url.endsWith("proxyerr.html")) {
|
||||
if (tab.cookieStoreId == context[0].cookieStoreId) {
|
||||
function onProxyErrorUpdated() {
|
||||
console.warn(`(proxy) Updated tab : ` + tab);
|
||||
console.warn("(proxy) Updated tab : " + tab);
|
||||
}
|
||||
|
||||
function onProxyError(error) {
|
||||
console.error(`(proxy) Error : ${error}`);
|
||||
}
|
||||
let createData = {
|
||||
url: "proxyerr.html",
|
||||
url: "proxyerr.html"
|
||||
};
|
||||
let creating = browser.tabs.update(tab.id, createData);
|
||||
creating.then(onProxyErrorUpdated, onProxyError);
|
||||
@@ -513,11 +364,11 @@ function handleContextProxyError(err) {
|
||||
}
|
||||
|
||||
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("(proxy) restoring proxy scheme:", proxy_scheme());
|
||||
console.log("(proxy) restoring proxy host:", proxy_host());
|
||||
console.log("(proxy) restoring proxy port:", proxy_port());
|
||||
console.log("(proxy) restoring control host:", control_host());
|
||||
console.log("(proxy) restoring control port:", control_port());
|
||||
}
|
||||
|
||||
function updateFromStorage() {
|
||||
@@ -529,13 +380,13 @@ function updateFromStorage() {
|
||||
});
|
||||
}
|
||||
|
||||
updateFromStorage();
|
||||
//updateFromStorage();
|
||||
browser.storage.onChanged.addListener(updateFromStorage);
|
||||
SetupSettings();
|
||||
setupProxy();
|
||||
|
||||
var gettingListenerInfo = browser.runtime.getPlatformInfo();
|
||||
gettingListenerInfo.then((got) => {
|
||||
gettingListenerInfo.then(got => {
|
||||
if (browser.windows != undefined) {
|
||||
browser.windows.onCreated.addListener(() => {
|
||||
chrome.storage.local.get(function () {
|
||||
|
644
scrub-2.js
644
scrub-2.js
@@ -1,644 +0,0 @@
|
||||
/* eslint-disable max-len */
|
||||
var titlepref = chrome.i18n.getMessage("titlePreface");
|
||||
var webpref = chrome.i18n.getMessage("webPreface");
|
||||
var routerpref = chrome.i18n.getMessage("routerPreface");
|
||||
var mailpref = chrome.i18n.getMessage("mailPreface");
|
||||
var torrentpref = chrome.i18n.getMessage("torrentPreface");
|
||||
var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
|
||||
var ircpref = chrome.i18n.getMessage("ircPreface");
|
||||
var extensionpref = chrome.i18n.getMessage("extensionPreface");
|
||||
var muwirepref = chrome.i18n.getMessage("muwirePreface");
|
||||
var botepref = chrome.i18n.getMessage("botePreface");
|
||||
var blogpref = chrome.i18n.getMessage("blogPreface");
|
||||
var blogprefpriv = chrome.i18n.getMessage("blogPrefacePrivate");
|
||||
var torpref = chrome.i18n.getMessage("torPreface");
|
||||
var torprefpriv = chrome.i18n.getMessage("torPrefacePrivate");
|
||||
|
||||
function contextScrub(requestDetails) {
|
||||
function handleHeaderError() {
|
||||
// log error message
|
||||
console.log("Error: Header could not be scrubbed");
|
||||
}
|
||||
function headerScrub() {
|
||||
const titlePrefix = "myob";
|
||||
const userAgent = "MYOB/6.66 (AN/ON)";
|
||||
if (requestDetails && requestDetails.name === titlePrefix) {
|
||||
for (const header of requestDetails.requestHeaders) {
|
||||
if (header.name.toLowerCase() === "user-agent") {
|
||||
header.value = userAgent;
|
||||
}
|
||||
}
|
||||
return { requestHeaders: requestDetails.requestHeaders };
|
||||
}
|
||||
}
|
||||
async function getContext(tabInfo) {
|
||||
try {
|
||||
const context = await browser.contextualIdentities.get(
|
||||
tabInfo.cookieStoreId
|
||||
);
|
||||
return context;
|
||||
} catch (error) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (requestDetails.tabId > 0) {
|
||||
let tab = getTab(requestDetails.tabId);
|
||||
let context = tab.then(getContext, handleHeaderError);
|
||||
let req = context.then(headerScrub, handleHeaderError);
|
||||
return req;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(scrub)Not scrubbing non-I2P request.", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function getTab(tabId) {
|
||||
try {
|
||||
let tabInfo = await browser.tabs.get(tabId);
|
||||
return tabInfo;
|
||||
} catch (error) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function i2pTabFind(tabId) {
|
||||
console.info("(isolate)Context Discovery browser", tabId);
|
||||
try {
|
||||
return forceIntoIsolation(tabId, titlepref, false);
|
||||
} catch (error) {
|
||||
console.error("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
function routerTabFind(tabId) {
|
||||
console.info("(isolate)Context Discovery console");
|
||||
try {
|
||||
return forceIntoIsolation(tabId, routerpref, true);
|
||||
} catch (error) {
|
||||
console.error("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
function i2ptunnelTabFind(tabId) {
|
||||
console.info("(isolate)Context Discovery browser");
|
||||
try {
|
||||
return forceIntoIsolation(tabId, tunnelpref, true);
|
||||
} catch (error) {
|
||||
console.error("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function snarkTabFind(tabId) {
|
||||
console.info("(isolate)Context Discovery torrents");
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: torrentpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
var exemptContext = await browser.contextualIdentities.query({
|
||||
name: titlepref
|
||||
});
|
||||
let tmp = new URL(tabId.url);
|
||||
console.log("(isolate)tabid host", tmp.host);
|
||||
if (!requestDetails.url.includes("snark/" + tmp.host)) {
|
||||
// if (tabId.cookieStoreId != exemptContext[0].cookieStoreId){
|
||||
function Create() {
|
||||
function onCreated(tab) {
|
||||
function closeOldTab(tabs) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log(
|
||||
"(isolate) Closing un-isolated tab",
|
||||
tabId.id,
|
||||
"in favor of",
|
||||
tab.id,
|
||||
"with context",
|
||||
tab.cookieStoreId
|
||||
);
|
||||
browser.tabs.remove(tabId.id);
|
||||
browser.tabs.move(tab.id, { index: 0 });
|
||||
}
|
||||
for (let index = 0; index < tabs.length; index++) {
|
||||
if (index != tabs.length - 1) {
|
||||
browser.tabs.remove(tabs[index].id);
|
||||
}
|
||||
}
|
||||
}
|
||||
var pins = browser.tabs.query({
|
||||
cookieStoreId: context[0].cookieStoreId
|
||||
});
|
||||
pins.then(closeOldTab, onScrubError);
|
||||
}
|
||||
if (requestDetails.url.endsWith("xhr1.html")) {
|
||||
let hostname = url.split("/")[2];
|
||||
let prefix = url.substr(0, url.indexOf("://") + 3);
|
||||
requestDetails.url = prefix + hostname + "/i2psnark/";
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
pinned: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url
|
||||
});
|
||||
created.then(onCreated, onContextError);
|
||||
}
|
||||
var gettab = browser.tabs.get(tabId.id);
|
||||
gettab.then(Create, onContextError);
|
||||
return tabId;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
function muwireTabFind(tabId) {
|
||||
console.info("(isolate)Context Discovery muwire");
|
||||
try {
|
||||
return forceIntoIsolation(tabId, muwirepref, true);
|
||||
} catch (error) {
|
||||
console.error("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
function i2pboteTabFind(tabId) {
|
||||
console.info("(isolate)Context Discovery bote");
|
||||
try {
|
||||
return forceIntoIsolation(tabId, botepref, true);
|
||||
} catch (error) {
|
||||
console.error("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
function mailTabFind(tabId) {
|
||||
console.info("(isolate)Context Discovery mail");
|
||||
try {
|
||||
return forceIntoIsolation(tabId, mailpref, true);
|
||||
} catch (error) {
|
||||
console.error("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
function ircTabFind(tabId) {
|
||||
console.info("(isolate)Context Discovery irc");
|
||||
try {
|
||||
return forceIntoIsolation(tabId, ircpref, true);
|
||||
} catch (error) {
|
||||
console.error("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
function torTabFind(tabId) {
|
||||
console.info("(isolate)Context Discovery tor");
|
||||
try {
|
||||
return forceIntoIsolation(tabId, torpref, true);
|
||||
} catch (error) {
|
||||
console.error("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
function blogTabFind(tabId) {
|
||||
console.info("(isolate)Context Discovery blog");
|
||||
try {
|
||||
return forceIntoIsolation(tabId, blogpref, true);
|
||||
} catch (error) {
|
||||
console.error("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function forceIntoIsolation(tabId, contextidentifier, pin = true) {
|
||||
console.info("(isolate) forcing context for", tabId, contextidentifier, pin);
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: contextidentifier
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
function Create(beforeTab) {
|
||||
console.info("(isolate) isolating before tab:", beforeTab);
|
||||
function onCreated(afterTab) {
|
||||
console.info("(isolate) created isolated tab:", afterTab);
|
||||
function closeOldTab(tabs) {
|
||||
console.info("(isolate) cleaning up tab:", beforeTab);
|
||||
console.info(
|
||||
"(isolate) Closing un-isolated tab",
|
||||
tabId.id,
|
||||
"in favor of",
|
||||
beforeTab.id,
|
||||
"with context",
|
||||
beforeTab.cookieStoreId
|
||||
);
|
||||
browser.tabs.remove(tabId.id);
|
||||
if (pin) {
|
||||
browser.tabs.move(beforeTab.id, { index: 0 });
|
||||
for (let index = 0; index < tabs.length; index++) {
|
||||
if (index != tabs.length - 1) {
|
||||
browser.tabs.remove(tabs[index].id);
|
||||
}
|
||||
}
|
||||
}
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tabId.id,
|
||||
popup: "security.html"
|
||||
});
|
||||
browser.pageAction.show(tabId.id);
|
||||
}
|
||||
var pins = browser.tabs.query({
|
||||
cookieStoreId: context[0].cookieStoreId
|
||||
});
|
||||
pins.then(closeOldTab, onScrubError);
|
||||
return afterTab;
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: beforeTab.url,
|
||||
pinned: pin
|
||||
});
|
||||
return created.then(onCreated, onContextError);
|
||||
}
|
||||
var gettab = browser.tabs.get(tabId.id);
|
||||
var tab = gettab.then(Create, onContextError);
|
||||
return tab;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("(isolate)Context Error", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function findOtherContexts() {
|
||||
const prefs = [
|
||||
"titlepref",
|
||||
"routerpref",
|
||||
"mailpref",
|
||||
"torrentpref",
|
||||
"tunnelpref",
|
||||
"ircpref",
|
||||
"muwirepref",
|
||||
"botepref",
|
||||
"blogpref",
|
||||
"torpref"
|
||||
];
|
||||
const contexts = await browser.contextualIdentities.query({});
|
||||
const myContexts = await Promise.all(
|
||||
prefs.map(pref => browser.contextualIdentities.query({ name: pref }))
|
||||
);
|
||||
const otherContexts = contexts.filter(
|
||||
context => !myContexts.some(
|
||||
myContext => myContext[0].cookieStoreId === context.cookieStoreId
|
||||
)
|
||||
);
|
||||
return otherContexts;
|
||||
}
|
||||
|
||||
function contextSetup(requestDetails) {
|
||||
try {
|
||||
async function tabGet(tabId) {
|
||||
try {
|
||||
//console.log("(isolate)Tab ID from Request", tabId);
|
||||
let tabInfo = await browser.tabs.get(tabId);
|
||||
return tabInfo;
|
||||
} catch (error) {
|
||||
console.log("(isolate)Tab error", error);
|
||||
}
|
||||
}
|
||||
if (requestDetails == undefined) {
|
||||
return requestDetails;
|
||||
}
|
||||
if (proxyHost(requestDetails)) {
|
||||
let setcookie = browser.cookies.set({
|
||||
firstPartyDomain: i2pHostName(requestDetails.url),
|
||||
url: requestDetails.url,
|
||||
secure: true
|
||||
});
|
||||
setcookie.then(onContextGotLog, onContextError);
|
||||
return requestDetails;
|
||||
}
|
||||
|
||||
if (requestDetails.tabId > 0) {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
tab.then(isolate);
|
||||
|
||||
function isolate() {
|
||||
const url = requestDetails.url;
|
||||
const localhost = localHost(url);
|
||||
const routerhost = routerHost(url);
|
||||
console.info("routerhost:", routerhost);
|
||||
console.info("localhost:", localhost);
|
||||
function tabUpdate(outboundTab) {
|
||||
if (outboundTab) {
|
||||
console.info("updating", outboundTab);
|
||||
browser.tabs.update(outboundTab.id, { url });
|
||||
}
|
||||
}
|
||||
if (routerhost) {
|
||||
let routertab = {};
|
||||
switch (routerhost) {
|
||||
case "i2ptunnelmgr":
|
||||
routertab = tab.then(i2ptunnelTabFind, onContextError);
|
||||
routertab.then(tabUpdate);
|
||||
return requestDetails;
|
||||
case "i2psnark":
|
||||
routertab = tab.then(snarkTabFind, onContextError);
|
||||
routertab.then(tabUpdate);
|
||||
return requestDetails;
|
||||
case "webmail":
|
||||
routertab = tab.then(mailTabFind, onContextError);
|
||||
routertab.then(tabUpdate);
|
||||
return requestDetails;
|
||||
case "muwire":
|
||||
routertab = tab.then(muwireTabFind, onContextError);
|
||||
routertab.then(tabUpdate);
|
||||
return requestDetails;
|
||||
case "i2pbote":
|
||||
routertab = tab.then(i2pboteTabFind, onContextError);
|
||||
routertab.then(tabUpdate);
|
||||
return requestDetails;
|
||||
case "routerconsole":
|
||||
routertab = tab.then(routerTabFind, onContextError);
|
||||
routertab.then(tabUpdate);
|
||||
return requestDetails;
|
||||
default:
|
||||
return requestDetails;
|
||||
}
|
||||
} else if (localhost) {
|
||||
let routertab = {};
|
||||
switch (localhost) {
|
||||
case "blog":
|
||||
routertab = tab.then(blogTabFind, onContextError);
|
||||
routertab.then(tabUpdate);
|
||||
return requestDetails;
|
||||
case "irc":
|
||||
routertab = tab.then(ircTabFind, onContextError);
|
||||
routertab.then(tabUpdate);
|
||||
return requestDetails;
|
||||
case "tor":
|
||||
routertab = tab.then(torTabFind, onContextError);
|
||||
routertab.then(tabUpdate);
|
||||
return requestDetails;
|
||||
default:
|
||||
return requestDetails;
|
||||
}
|
||||
} else if (i2pHost(requestDetails)) {
|
||||
const thn = i2pHostName(url);
|
||||
if (url.includes("=" + thn)) {
|
||||
if (
|
||||
!url.includes("://github.com") ||
|
||||
!url.includes("://notabug.org") ||
|
||||
!url.includes("://i2pgit.org") ||
|
||||
!url.includes("://gitlab.com")
|
||||
) {
|
||||
console.log("(scrub)checking search hostnames =" + thn);
|
||||
const tpt = url.split("=" + thn, 2);
|
||||
requestDetails.url =
|
||||
"http://" + thn + "/" + tpt[1].replace("%2F", "");
|
||||
}
|
||||
}
|
||||
console.log("(scrub) new hostname", url);
|
||||
const setcookie = browser.cookies.set({
|
||||
firstPartyDomain: i2pHostName(url),
|
||||
url,
|
||||
secure: true
|
||||
});
|
||||
setcookie.then(onContextGotLog, onContextError);
|
||||
const i2ptab = tab.then(i2pTabFind, onContextError);
|
||||
i2ptab.then(tabUpdate);
|
||||
return requestDetails;
|
||||
} else if (extensionHost(requestDetails)) {
|
||||
return requestDetails;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(isolate)Not an I2P request, blackholing", error);
|
||||
}
|
||||
}
|
||||
|
||||
function coolheadersSetup(incomingHeaders) {
|
||||
var asyncSetPageAction = new Promise((resolve, reject) => {
|
||||
window.setTimeout(() => {
|
||||
if (incomingHeaders.tabId != undefined) {
|
||||
let popup = browser.pageAction.getPopup({
|
||||
tabId: incomingHeaders.tabId
|
||||
});
|
||||
popup.then(gotPopup);
|
||||
}
|
||||
|
||||
resolve({ responseHeaders: incomingHeaders.responseHeaders });
|
||||
}, 2000);
|
||||
});
|
||||
return asyncSetPageAction;
|
||||
}
|
||||
|
||||
function getTabURL(tab) {
|
||||
console.log("(scrub)(equiv check) popup check", tab);
|
||||
|
||||
if (tab.id != undefined) {
|
||||
let popup = browser.pageAction.getPopup({ tabId: tab.id });
|
||||
console.log("(scrub)(equiv check) popup check");
|
||||
popup.then(gotPopup);
|
||||
}
|
||||
}
|
||||
|
||||
function gotPopup(pageTest, tab) {
|
||||
if (pageTest === undefined) {
|
||||
return;
|
||||
}
|
||||
console.info("pageTest:", pageTest);
|
||||
let isHttps = false;
|
||||
let isI2p = false;
|
||||
if (tab === undefined) {
|
||||
return;
|
||||
}
|
||||
isHttps = tab.url.startsWith("https://");
|
||||
isI2p = tab.url.includes(".i2p");
|
||||
if (isHttps) {
|
||||
if (isI2p) {
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tab.id,
|
||||
popup: "security.html"
|
||||
});
|
||||
browser.pageAction.setIcon({
|
||||
path: "icons/infotoopies.png",
|
||||
tabId: tab.id
|
||||
});
|
||||
|
||||
try {
|
||||
browser.tabs
|
||||
.sendMessage(tab.id, { req: "i2p-torrentlocation" })
|
||||
.then(response => {
|
||||
if (
|
||||
response &&
|
||||
response.content.toUpperCase() !== "NO-ALT-LOCATION"
|
||||
) {
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tab.id,
|
||||
popup: "torrent.html"
|
||||
});
|
||||
browser.pageAction.setIcon({
|
||||
path: "icons/infotoopiesbt.png",
|
||||
tabId: tab.id
|
||||
});
|
||||
browser.pageAction.setTitle({
|
||||
tabId: tab.id,
|
||||
title: response.content
|
||||
});
|
||||
browser.pageAction.show(tab.id);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("(scrub)(equiv check)", err);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
browser.tabs
|
||||
.sendMessage(tab.id, { req: "i2p-location" })
|
||||
.then(response => {
|
||||
if (
|
||||
response &&
|
||||
response.content.toUpperCase() !== "NO-ALT-LOCATION"
|
||||
) {
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tab.id,
|
||||
popup: "location.html"
|
||||
});
|
||||
browser.pageAction.setIcon({
|
||||
path: "icons/i2plogo.png",
|
||||
tabId: tab.id
|
||||
});
|
||||
browser.pageAction.setTitle({
|
||||
tabId: tab.id,
|
||||
title: response.content
|
||||
});
|
||||
browser.pageAction.show(tab.id);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("(scrub)(equiv check)", err);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isI2p) {
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tab.id,
|
||||
popup: "security.html"
|
||||
});
|
||||
browser.pageAction.setIcon({
|
||||
path: "icons/infotoopie.png",
|
||||
tabId: tab.id
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
browser.tabs
|
||||
.sendMessage(tab.id, { req: "i2p-torrentlocation" })
|
||||
.then(response => {
|
||||
if (
|
||||
response &&
|
||||
response.content.toUpperCase() !== "NO-ALT-LOCATION"
|
||||
) {
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tab.id,
|
||||
popup: "torrent.html"
|
||||
});
|
||||
browser.pageAction.setIcon({
|
||||
path: "icons/infotoopiebt.png",
|
||||
tabId: tab.id
|
||||
});
|
||||
browser.pageAction.setTitle({
|
||||
tabId: tab.id,
|
||||
title: response.content
|
||||
});
|
||||
browser.pageAction.show(tab.id);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("(pageaction)", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getClearTab(tab) {
|
||||
function setupTabs() {
|
||||
if (typeof tab === "number") {
|
||||
browser.tabs.get(tab).then(getTabURL, onScrubError);
|
||||
} else if (typeof tab === "object" && typeof tab.tabId === "number") {
|
||||
browser.tabs.get(tab.tabId).then(getTabURL, onScrubError);
|
||||
} else if (typeof tab === "object" && Array.isArray(tab.tabIds)) {
|
||||
for (let tabId of tab.tabIds) {
|
||||
browser.tabs.get(tabId).then(getTabURL, onScrubError);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tab === undefined) {
|
||||
browser.tabs.query({}).then(setupTabs);
|
||||
} else {
|
||||
setupTabs();
|
||||
}
|
||||
}
|
||||
|
||||
const filter = {
|
||||
url: [{ hostContains: ".i2p" }]
|
||||
};
|
||||
|
||||
function logOnDOMContentLoaded(details) {
|
||||
console.log(`onDOMContentLoaded: ${details.url}`);
|
||||
}
|
||||
|
||||
browser.tabs.onActivated.addListener(getClearTab);
|
||||
browser.tabs.onAttached.addListener(getClearTab);
|
||||
browser.tabs.onCreated.addListener(getClearTab);
|
||||
browser.tabs.onDetached.addListener(getClearTab);
|
||||
browser.tabs.onHighlighted.addListener(getClearTab);
|
||||
browser.tabs.onMoved.addListener(getClearTab);
|
||||
browser.tabs.onReplaced.addListener(getClearTab);
|
||||
|
||||
browser.pageAction.onClicked.addListener(getClearTab);
|
||||
|
||||
function reloadTabs(tabs) {
|
||||
for (let tab of tabs) {
|
||||
browser.tabs.reload(tab.id);
|
||||
}
|
||||
}
|
||||
|
||||
function reloadError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
let querying = browser.tabs.query({});
|
||||
querying.then(reloadTabs, onScrubError);
|
||||
|
||||
/* Listen for onHeaderReceived for the target page.
|
||||
Set "blocking" and "responseHeaders". */
|
||||
browser.webRequest.onHeadersReceived.addListener(
|
||||
coolheadersSetup,
|
||||
{ urls: [
|
||||
"*://*.i2p/*",
|
||||
"https://*/*"
|
||||
] },
|
||||
["responseHeaders"]
|
||||
);
|
||||
|
||||
browser.webNavigation.onDOMContentLoaded.addListener(getClearTab, filter);
|
||||
browser.webNavigation.onDOMContentLoaded.addListener(
|
||||
logOnDOMContentLoaded,
|
||||
filter
|
||||
);
|
||||
|
||||
browser.webRequest.onBeforeRequest.addListener(contextSetup, {
|
||||
urls: [
|
||||
"*://*.i2p/*",
|
||||
"*://localhost/*",
|
||||
"*://127.0.0.1/*",
|
||||
"*://*/*i2p*"
|
||||
]
|
||||
});
|
||||
|
||||
browser.webRequest.onBeforeSendHeaders.addListener(
|
||||
contextScrub,
|
||||
{ urls: ["*://*.i2p/*"] },
|
||||
["requestHeaders"]
|
||||
);
|
||||
|
||||
function onScrubError(err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
function onContextGotLog(log) {
|
||||
console.log(log);
|
||||
}
|
||||
|
||||
function onContextError(err) {
|
||||
console.error("Context launcher error:", err);
|
||||
}
|
Reference in New Issue
Block a user