take way too much time to fix a couple of commas
This commit is contained in:
@@ -131,6 +131,10 @@
|
||||
"message": "I2P Browser (Private)",
|
||||
"description": "Preface for the browser titlebar"
|
||||
},
|
||||
"extensionPreface": {
|
||||
"message": "I2P Management",
|
||||
"description": "Preface for the browser titlebar"
|
||||
},
|
||||
"webPreface": {
|
||||
"message": "Web Browser",
|
||||
"description": "Preface for the browser titlebar"
|
||||
|
@@ -12,6 +12,7 @@ var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
|
||||
var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate");
|
||||
var localpref = chrome.i18n.getMessage("localPreface");
|
||||
var localprefpriv = chrome.i18n.getMessage("localPrefacePrivate");
|
||||
var extensionpref = chrome.i18n.getMessage("extensionPreface");
|
||||
|
||||
function onContextsGot(contexts) {
|
||||
var ids = [];
|
||||
@@ -29,6 +30,15 @@ function onContextsGot(contexts) {
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
if (ids.indexOf(extensionpref) == -1) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: extensionpref,
|
||||
color: "pink",
|
||||
icon: "gift"
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
if (ids.indexOf(webpref) == -1) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
|
6
config.js
Normal file
6
config.js
Normal file
@@ -0,0 +1,6 @@
|
||||
var proxy_scheme = "HTTP";
|
||||
var proxy_host = "127.0.0.1";
|
||||
var proxy_port = "4444";
|
||||
var control_host = "127.0.0.1";
|
||||
var control_port = "7657";
|
||||
var disable_history = false;
|
@@ -50,12 +50,3 @@ fetch("http://proxy.i2p").then(myJson => {
|
||||
console.log("FETCH RESULT", myJson);
|
||||
contentUpdateById("proxy-check", "proxySuccessStatus");
|
||||
});
|
||||
|
||||
UpdateContents();
|
||||
|
||||
const minutes = 0.2;
|
||||
const interval = minutes * 60 * 1000;
|
||||
|
||||
setInterval(function() {
|
||||
UpdateContents();
|
||||
}, interval);
|
||||
|
47
handler.js
47
handler.js
@@ -1,3 +1,50 @@
|
||||
function routerHost(url) {
|
||||
let hostname = "";
|
||||
let path = "";
|
||||
function pathcheck(str) {
|
||||
if (str != undefined) {
|
||||
let final = str.split("/")[0];
|
||||
if (final === "i2ptunnelmgr" || final === "i2ptunnel") {
|
||||
console.log("(urlcheck) application path", final);
|
||||
return "i2ptunnelmgr";
|
||||
} else if (final === "i2psnark" || final === "torrents") {
|
||||
console.log("(urlcheck) application path", final);
|
||||
return "i2psnark";
|
||||
} else if (final === "webmail" || final === "susimail") {
|
||||
console.log("(urlcheck) application path", final);
|
||||
return "webmail";
|
||||
} else if (
|
||||
final === "home" ||
|
||||
final === "console" ||
|
||||
final === "dns" ||
|
||||
final.startsWith("themes") ||
|
||||
final.startsWith("config")
|
||||
) {
|
||||
console.log("(urlcheck) 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);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function identifyProtocolHandler(url) {
|
||||
//console.log("looking for handler-able requests")
|
||||
if (routerHost(url)) {
|
||||
|
7
host.js
7
host.js
@@ -29,8 +29,10 @@ function localHost(url) {
|
||||
}
|
||||
|
||||
function extensionHost(url) {
|
||||
var res = url.startsWith(browser.runtime.getURL(""));
|
||||
return res;
|
||||
var res = url.originUrl.startsWith(browser.runtime.getURL(""));
|
||||
if (res) return res;
|
||||
var res = url.url.startsWith(browser.runtime.getURL(""));
|
||||
if (res) return res;
|
||||
}
|
||||
|
||||
function i2pHostName(url) {
|
||||
@@ -66,6 +68,7 @@ function routerHost(url) {
|
||||
} else if (
|
||||
final === "home" ||
|
||||
final === "console" ||
|
||||
final === "dns" ||
|
||||
final.startsWith("config")
|
||||
) {
|
||||
console.log("(urlcheck) application path", final);
|
||||
|
@@ -12,11 +12,11 @@ function makeid(length) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function send(message) {
|
||||
function send(message, control_host = "127.0.0.1", control_port = "7657") {
|
||||
async function postData(url = "", data = {}) {
|
||||
// Default options are marked with *
|
||||
//console.log("(i2pcontrol)");
|
||||
let requestBody = JSON.stringify(data);
|
||||
//console.log("(i2pcontrol)", requestBody, data);
|
||||
let opts = {
|
||||
method: "POST", // *GET, POST, PUT, DELETE, etc.
|
||||
mode: "cors", // no-cors, *cors, same-origin
|
||||
@@ -33,23 +33,32 @@ function send(message) {
|
||||
return await response.json(); // parses JSON response into native JavaScript objects
|
||||
}
|
||||
|
||||
return postData("http://127.0.0.1:7657/jsonrpc/", message);
|
||||
return postData(
|
||||
"http://" + control_host + ":" + control_port + "/jsonrpc/",
|
||||
message
|
||||
);
|
||||
}
|
||||
|
||||
function authenticate(password) {
|
||||
var json = {
|
||||
id: makeid(6),
|
||||
jsonrpc: "2.0",
|
||||
method: "Authenticate",
|
||||
params: {
|
||||
API: 1,
|
||||
Password: password
|
||||
}
|
||||
};
|
||||
function authenticate(
|
||||
password,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657"
|
||||
) {
|
||||
var json = new Object();
|
||||
json["id"] = makeid(6);
|
||||
json["jsonrpc"] = "2.0";
|
||||
json["method"] = "Authenticate";
|
||||
json["params"] = new Object();
|
||||
json["params"]["API"] = 1;
|
||||
json["params"]["Password"] = password;
|
||||
return send(json);
|
||||
}
|
||||
|
||||
async function GetToken(password) {
|
||||
async function GetToken(
|
||||
password,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657"
|
||||
) {
|
||||
let me = authenticate(password);
|
||||
return await me.then(gettoken);
|
||||
}
|
||||
@@ -63,17 +72,15 @@ function Done(output) {
|
||||
return output;
|
||||
}
|
||||
|
||||
function Echo(message) {
|
||||
function Echo(message, control_host = "127.0.0.1", control_port = "7657") {
|
||||
function echo(token) {
|
||||
let json = {
|
||||
id: makeid(6),
|
||||
jsonrpc: "2.0",
|
||||
method: "Echo",
|
||||
params: {
|
||||
Token: token,
|
||||
Echo: message
|
||||
}
|
||||
};
|
||||
var json = new Object();
|
||||
json["id"] = makeid(6);
|
||||
json["jsonrpc"] = "2.0";
|
||||
json["method"] = "Echo";
|
||||
json["params"] = new Object();
|
||||
json["params"]["Token"] = token;
|
||||
json["params"]["Echo"] = message;
|
||||
return send(json);
|
||||
}
|
||||
let token = GetToken(password);
|
||||
@@ -81,16 +88,21 @@ function Echo(message) {
|
||||
return done;
|
||||
}
|
||||
|
||||
function UpdateEchoElementByID(Query, ID) {
|
||||
function UpdateEchoElementByID(
|
||||
Query,
|
||||
ID,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657"
|
||||
) {
|
||||
function updateelement(update) {
|
||||
//console.log("(i2pcontrol)", update);
|
||||
document.getElementById(ID).innerText = update;
|
||||
}
|
||||
let net = Echo(Query);
|
||||
let net = Echo(Query, control_host, control_port);
|
||||
net.then(updateleement);
|
||||
}
|
||||
|
||||
function GetRate(Query) {
|
||||
function GetRate(Query, control_host = "127.0.0.1", control_port = "7657") {
|
||||
function getrate(token) {
|
||||
var json = new Object();
|
||||
json["id"] = makeid(6);
|
||||
@@ -107,16 +119,21 @@ function GetRate(Query) {
|
||||
return done;
|
||||
}
|
||||
|
||||
function UpdateGetRateElementByID(Query, ID) {
|
||||
function UpdateGetRateElementByID(
|
||||
Query,
|
||||
ID,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657"
|
||||
) {
|
||||
function updateelement(update) {
|
||||
console.log("(i2pcontrol)", update);
|
||||
//console.log("(i2pcontrol)", update);
|
||||
document.getElementById(ID).innerText = update;
|
||||
}
|
||||
let net = GetRate(Query);
|
||||
let net = GetRate(Query, control_host, control_port);
|
||||
net.then(updateleement);
|
||||
}
|
||||
|
||||
function I2PControl(Query) {
|
||||
function I2PControl(Query, control_host = "127.0.0.1", control_port = "7657") {
|
||||
function i2pcontrol(token) {
|
||||
var json = new Object();
|
||||
json["id"] = makeid(6);
|
||||
@@ -132,16 +149,21 @@ function I2PControl(Query) {
|
||||
return done;
|
||||
}
|
||||
|
||||
function UpdateI2PControlElementByID(Query, ID) {
|
||||
function UpdateI2PControlElementByID(
|
||||
Query,
|
||||
ID,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657"
|
||||
) {
|
||||
function updateelement(update) {
|
||||
//console.log("(i2pcontrol)", update);
|
||||
document.getElementById(ID).innerText = update;
|
||||
}
|
||||
let net = I2PControl(Query);
|
||||
let net = I2PControl(Query, control_host, control_port);
|
||||
net.then(updateleement);
|
||||
}
|
||||
|
||||
function RouterInfo(Query) {
|
||||
function RouterInfo(Query, control_host = "127.0.0.1", control_port = "7657") {
|
||||
function routerinfo(token) {
|
||||
var json = new Object();
|
||||
json["id"] = makeid(6);
|
||||
@@ -157,21 +179,30 @@ function RouterInfo(Query) {
|
||||
return done;
|
||||
}
|
||||
|
||||
function UpdateRouterInfoElementByID(Query, ID) {
|
||||
function UpdateRouterInfoElementByID(
|
||||
Query,
|
||||
ID,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657"
|
||||
) {
|
||||
function updateelement(update) {
|
||||
//console.log(
|
||||
//"(i2pcontrol)",
|
||||
//update.result[Query],
|
||||
//ID,
|
||||
//document.getElementById(ID)
|
||||
//);
|
||||
/*console.log(
|
||||
"(i2pcontrol)",
|
||||
update.result[Query],
|
||||
ID,
|
||||
document.getElementById(ID)
|
||||
);*/
|
||||
document.getElementById(ID).innerText = update.result[Query];
|
||||
}
|
||||
let net = RouterInfo(Query);
|
||||
let net = RouterInfo(Query, control_host, control_port);
|
||||
net.then(updateelement);
|
||||
}
|
||||
|
||||
function RouterManager(Query) {
|
||||
function RouterManager(
|
||||
Query,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657"
|
||||
) {
|
||||
function routermanager(token) {
|
||||
var json = new Object();
|
||||
json["id"] = makeid(6);
|
||||
@@ -187,16 +218,25 @@ function RouterManager(Query) {
|
||||
return done;
|
||||
}
|
||||
|
||||
function UpdateRouterManagerElementByID(Query, ID) {
|
||||
function UpdateRouterManagerElementByID(
|
||||
Query,
|
||||
ID,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657"
|
||||
) {
|
||||
function updateelement(update) {
|
||||
//console.log("(i2pcontrol)", update);
|
||||
document.getElementById(ID).innerText = update;
|
||||
}
|
||||
let net = RouterManage(Query);
|
||||
let net = RouterManage(Query, control_host, control_port);
|
||||
net.then(updateleement);
|
||||
}
|
||||
|
||||
function NetworkSetting(Query) {
|
||||
function NetworkSetting(
|
||||
Query,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657"
|
||||
) {
|
||||
function networksetting(token) {
|
||||
var json = new Object();
|
||||
json["id"] = makeid(6);
|
||||
@@ -212,12 +252,17 @@ function NetworkSetting(Query) {
|
||||
return done;
|
||||
}
|
||||
|
||||
function UpdateNetworkSettingElementByID(Query, ID) {
|
||||
function UpdateNetworkSettingElementByID(
|
||||
Query,
|
||||
ID,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657"
|
||||
) {
|
||||
function updateelement(update) {
|
||||
//console.log("(i2pcontrol)", update);
|
||||
document.getElementById(ID).innerText = update;
|
||||
}
|
||||
let net = NetworkSetting(Query);
|
||||
let net = NetworkSetting(Query, control_host, control_port);
|
||||
net.then(updateleement);
|
||||
}
|
||||
|
||||
@@ -268,5 +313,5 @@ function UpdateContents() {
|
||||
);
|
||||
}
|
||||
|
||||
//var done = Echo(hello);
|
||||
//done.then(Done);
|
||||
var done = Echo(hello);
|
||||
done.then(Done);
|
||||
|
21
info.js
21
info.js
@@ -145,12 +145,14 @@ function goHome() {
|
||||
};
|
||||
console.log("visiting homepage");
|
||||
let creating = browser.tabs.create(createRhizomeData);
|
||||
creating.then(onTabCreated, onTabError);
|
||||
} else {
|
||||
let createData = {
|
||||
url: "home.html"
|
||||
};
|
||||
console.log("visiting homepage");
|
||||
let creating = browser.tabs.create(createData);
|
||||
creating.then(onTabCreated, onTabError);
|
||||
}
|
||||
console.log("(bookmarks) adding home page bookmark");
|
||||
}
|
||||
@@ -168,7 +170,7 @@ function goIndex() {
|
||||
};
|
||||
console.log("visiting help");
|
||||
let creating = browser.tabs.create(createData);
|
||||
creating(onTabCreated, onTabError);
|
||||
creating.then(onTabCreated, onTabError);
|
||||
}
|
||||
|
||||
function goToopie() {
|
||||
@@ -180,7 +182,7 @@ function goToopie() {
|
||||
};
|
||||
console.log("visiting toopie");
|
||||
let creating = browser.tabs.create(createData);
|
||||
creating(onTabCreated, onTabError);
|
||||
creating.then(onTabCreated, onTabError);
|
||||
}
|
||||
|
||||
function onTabCreated() {
|
||||
@@ -199,7 +201,7 @@ function goSearch() {
|
||||
};
|
||||
console.log("visiting legwork");
|
||||
let creating = browser.tabs.create(createData);
|
||||
creating(onTabCreated, onTabError);
|
||||
creating.then(onTabCreated, onTabError);
|
||||
}
|
||||
|
||||
function goTunnel() {
|
||||
@@ -211,7 +213,7 @@ function goTunnel() {
|
||||
};
|
||||
console.log("visiting i2ptunnel");
|
||||
let creating = browser.tabs.create(createData);
|
||||
creating(onTabCreated, onTabError);
|
||||
creating.then(onTabCreated, onTabError);
|
||||
}
|
||||
|
||||
function goMail() {
|
||||
@@ -235,7 +237,7 @@ function goSnark() {
|
||||
};
|
||||
console.log("visiting snark");
|
||||
let creating = browser.tabs.create(createData);
|
||||
creating(onTabCreated, onTabError);
|
||||
creating.then(onTabCreated, onTabError);
|
||||
}
|
||||
|
||||
function onVisited(historyItem) {
|
||||
@@ -261,3 +263,12 @@ function onVisited(historyItem) {
|
||||
deletingUrl.then(onRemoved);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateContents();
|
||||
|
||||
const minutes = 0.2;
|
||||
const interval = minutes * 60 * 1000;
|
||||
|
||||
setInterval(function() {
|
||||
UpdateContents();
|
||||
}, interval);
|
||||
|
@@ -42,11 +42,12 @@
|
||||
},
|
||||
"background": {
|
||||
"scripts": [
|
||||
"privacy.js",
|
||||
"config.js",
|
||||
"i2pcontrol/i2pcontrol.js",
|
||||
"host.js",
|
||||
"privacy.js",
|
||||
"platform.js",
|
||||
"background.js",
|
||||
"host.js",
|
||||
"handler.js",
|
||||
"proxy.js",
|
||||
"info.js",
|
||||
|
@@ -1,12 +1,5 @@
|
||||
var titlepref = chrome.i18n.getMessage("titlePreface");
|
||||
|
||||
var proxy_scheme = "HTTP";
|
||||
var proxy_host = "127.0.0.1";
|
||||
var proxy_port = "4444";
|
||||
var control_host = "127.0.0.1";
|
||||
var control_port = "7657";
|
||||
var disable_history = false;
|
||||
|
||||
function onSet(result) {
|
||||
if (result) {
|
||||
console.log("->: Value was updated");
|
||||
|
21
scrub.js
21
scrub.js
@@ -5,6 +5,7 @@ var mailpref = chrome.i18n.getMessage("mailPreface");
|
||||
var torrentpref = chrome.i18n.getMessage("torrentPreface");
|
||||
var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
|
||||
var localpref = chrome.i18n.getMessage("localPreface");
|
||||
var extensionpref = chrome.i18n.getMessage("extensionPreface");
|
||||
|
||||
var contextScrub = async function(requestDetails) {
|
||||
function onHeaderError() {
|
||||
@@ -356,19 +357,19 @@ var contextSetup = function(requestDetails) {
|
||||
if (requestDetails == undefined) {
|
||||
return requestDetails;
|
||||
}
|
||||
if (extensionHost(requestDetails.url)) {
|
||||
if (proxyHost(requestDetails.url)) {
|
||||
setcookie = browser.cookies.set({
|
||||
firstPartyDomain: i2pHostName(requestDetails.url),
|
||||
url: requestDetails.url,
|
||||
secure: true
|
||||
});
|
||||
setcookie.then(onContextGotLog, onContextError);
|
||||
return requestDetails;
|
||||
}
|
||||
if (extensionHost(requestDetails)) {
|
||||
return requestDetails;
|
||||
}
|
||||
if (requestDetails.tabId > 0) {
|
||||
if (proxyHost(requestDetails.url)) {
|
||||
setcookie = browser.cookies.set({
|
||||
firstPartyDomain: i2pHostName(requestDetails.url),
|
||||
url: requestDetails.url,
|
||||
secure: true
|
||||
});
|
||||
setcookie.then(onContextGotLog, onContextError);
|
||||
return requestDetails;
|
||||
}
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
if (i2pHost(requestDetails.url)) {
|
||||
var setcookie = browser.cookies.set({
|
||||
|
Reference in New Issue
Block a user