Merge pull request #57 from eyedeekay/lint

First round of lint errors
This commit is contained in:
idk
2020-01-02 20:48:34 +00:00
committed by GitHub
12 changed files with 292 additions and 311 deletions

View File

@@ -36,8 +36,8 @@ clean:
## EVEN RELEASES are AMO RELEASES
## ODD RELEASES are SELFHOSTED RELEASES
MOZ_VERSION=0.52
VERSION=0.53
MOZ_VERSION=0.54
VERSION=0.55
#VERSION=$(MOZ_VERSION)
#VERSION=1.27

View File

@@ -27,7 +27,7 @@ function onContextsGot(contexts) {
color: "orange",
icon: "fingerprint"
})
.then(onCreated, onError);
.then(onCreated, onNotCreated);
}
if (ids.indexOf(webpref) == -1) {
browser.contextualIdentities
@@ -36,7 +36,7 @@ function onContextsGot(contexts) {
color: "red",
icon: "circle"
})
.then(onCreated, onError);
.then(onCreated, onNotCreated);
}
if (ids.indexOf(routerpref) == -1) {
browser.contextualIdentities
@@ -45,7 +45,7 @@ function onContextsGot(contexts) {
color: "blue",
icon: "briefcase"
})
.then(onCreated, onError);
.then(onCreated, onNotCreated);
}
if (ids.indexOf(tunnelpref) == -1) {
browser.contextualIdentities
@@ -54,7 +54,7 @@ function onContextsGot(contexts) {
color: "green",
icon: "tree"
})
.then(onCreated, onError);
.then(onCreated, onNotCreated);
}
if (ids.indexOf(mailpref) == -1) {
browser.contextualIdentities
@@ -63,7 +63,7 @@ function onContextsGot(contexts) {
color: "yellow",
icon: "briefcase"
})
.then(onCreated, onError);
.then(onCreated, onNotCreated);
}
if (ids.indexOf(torrentpref) == -1) {
browser.contextualIdentities
@@ -72,7 +72,7 @@ function onContextsGot(contexts) {
color: "purple",
icon: "chill"
})
.then(onCreated, onError);
.then(onCreated, onNotCreated);
}
if (ids.indexOf(localpref) == -1) {
browser.contextualIdentities
@@ -81,20 +81,27 @@ function onContextsGot(contexts) {
color: "red",
icon: "fence"
})
.then(onCreated, onError);
.then(onCreated, onNotCreated);
}
}
function onContextsError() {
console.log("Error finding contextual identities, is the API enabled?");
}
function onCreated(context) {
console.log(`New identity's ID: ${context.cookieStoreId}.`);
}
browser.contextualIdentities.query({}).then(onContextsGot, onError);
function onNotCreated(context) {
console.log(`identity ID: ${context.cookieStoreId} not created`);
}
browser.contextualIdentities.query({}).then(onContextsGot, onContextsError);
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
} else {
if (got.os != "android") {
browser.windows.onCreated.addListener(themeWindow);
browser.windows.onFocusChanged.addListener(themeWindow);
browser.windows.onRemoved.addListener(themeWindow);
@@ -105,19 +112,19 @@ gettingInfo.then(got => {
function themeWindowByTab(tabId) {
function tabWindow(tab) {
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
var gettingPlatformInfo = browser.runtime.getPlatformInfo();
gettingPlatformInfo.then(got => {
if (got.os == "android") {
getwindow = browser.tabs.get(tab.tabId);
let getwindow = browser.tabs.get(tab.tabId);
getwindow.then(themeWindow);
} else {
getwindow = browser.windows.get(tab.windowId);
let getwindow = browser.windows.get(tab.windowId);
getwindow.then(themeWindow);
}
});
}
if (typeof tabId === "number") {
tab = browser.tabs.get(tabId);
let tab = browser.tabs.get(tabId);
tab.then(tabWindow);
} else {
tabWindow(tabId);
@@ -125,17 +132,21 @@ function themeWindowByTab(tabId) {
}
function isEmpty(obj) {
if (obj == undefined || obj == null) return true;
if (obj === undefined || obj === null) {
return true;
}
for (var key in obj) {
if (obj.hasOwnProperty(key)) return false;
if (obj.hasOwnProperty(key)) {
return false;
}
}
return true;
}
var oldtheme;
var oldtheme = null;
var getOldTheme = async function getOldTheme() {
foundtheme = await browser.theme.getCurrent();
let foundtheme = await browser.theme.getCurrent();
if (!isEmpty(foundtheme)) {
oldtheme = foundtheme;
console.log("Found old theme", oldtheme);
@@ -240,8 +251,11 @@ function themeWindow(window) {
}
} else {
console.log("Not active in I2P window");
if (!isEmpty(oldtheme)) browser.theme.update(window.id, oldtheme);
else browser.theme.reset();
if (isEmpty(oldtheme)) {
browser.theme.reset();
} else {
browser.theme.update(window.id, oldtheme);
}
}
}
if (
@@ -252,8 +266,11 @@ function themeWindow(window) {
.get(tabInfo[0].cookieStoreId)
.then(onContextGotTheme, onThemeError);
} else {
if (!isEmpty(oldtheme)) browser.theme.update(window.id, oldtheme);
else browser.theme.reset();
if (isEmpty(oldtheme)) {
browser.theme.reset();
} else {
browser.theme.update(window.id, oldtheme);
}
}
}
@@ -261,10 +278,14 @@ function themeWindow(window) {
currentWindow: true,
active: true
});
querying.then(logTabs, onError);
querying.then(logTabs, onThemeError);
}
function setTitle(window) {
// Check if the window is in private browsing
function onContextError() {
console.log("Context Error");
}
function logTabs(tabInfo) {
function onContextGotTitle(context) {
if (context.name == titlepref) {
@@ -283,11 +304,11 @@ function setTitle(window) {
console.log("Active in Web window");
if (window.incognito) {
browser.windows.update(window.id, {
titlePreface: ""
titlePreface: webprefpriv + " - "
});
} else {
browser.windows.update(window.id, {
titlePreface: ""
titlePreface: webpref + " - "
});
}
} else if (context.name == routerpref) {
@@ -358,7 +379,7 @@ function setTitle(window) {
) {
browser.contextualIdentities
.get(tabInfo[0].cookieStoreId)
.then(onContextGotTitle, onError);
.then(onContextGotTitle, onContextError);
} else if (window.incognito) {
browser.windows.update(window.id, {
titlePreface: ""
@@ -374,27 +395,38 @@ function setTitle(window) {
currentWindow: true,
active: true
});
querying.then(logTabs, onError);
querying.then(logTabs, onContextError);
}
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
} else {
var gettingListenerInfo = browser.runtime.getPlatformInfo();
gettingListenerInfo.then(got => {
function onPlatformError() {
console.log("Error finding platform info");
}
if (got.os != "android") {
browser.windows.onCreated.addListener(() => {
/* var gettingStoredSettings = chrome.storage.local.get();
gettingStoredSettings.then(setupProxy, onError); */
chrome.storage.local.get(function(got) {
chrome.storage.local.get(function() {
setupProxy();
});
});
browser.tabs.onCreated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
});
getting.then(setTitle, onPlatformError);
});
browser.tabs.onActivated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
});
getting.then(setTitle, onPlatformError);
});
}
});
/*
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
} else {
if (got.os != "android") {
browser.tabs.onCreated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
@@ -403,11 +435,9 @@ gettingInfo.then(got => {
});
}
});
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
} else {
if (got.os != "android") {
browser.tabs.onActivated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
@@ -416,7 +446,7 @@ gettingInfo.then(got => {
});
}
});
*/
function handleUpdated(updateInfo) {
if (updateInfo.theme) {
console.log(`Theme was applied: ${updateInfo.theme}`);

View File

@@ -6,17 +6,16 @@ gettingInfo.then(got => {
function bookHome(bookmarkItems) {
if (!bookmarkItems.length) {
function gotProxyInfo(info) {
let host = info.value.http.split(":")[0];
let port = info.value.http.split(":")[1];
if (port == "7644") {
var createBookmark = browser.bookmarks.create({
let createRhizomeBookmark = browser.bookmarks.create({
url: "about:I2p",
title: "I2P Home Page",
parentId: bookmarkToolbar[0].id
});
createBookmark.then(onCreated);
createRhizomeBookmark.then(onCreated);
} else {
var createBookmark = browser.bookmarks.create({
let createBookmark = browser.bookmarks.create({
url: browser.runtime.getURL("home.html"),
title: "I2P Home Page",
parentId: bookmarkToolbar[0].id
@@ -28,72 +27,69 @@ gettingInfo.then(got => {
console.log(
"(bookmarks) checking if we're running in an I2P Browser"
);
var gettingInfo = browser.proxy.settings.get({});
gettingInfo.then(gotProxyInfo);
let gettingProxyInfo = browser.proxy.settings.get({});
gettingProxyInfo.then(gotProxyInfo);
}
}
function bookTorrent(bookmarkItems) {
if (!bookmarkItems.length) {
function gotProxyInfo(info) {
let host = info.value.http.split(":")[0];
let port = info.value.http.split(":")[1];
if (port == "7644") {
var createBookmark = browser.bookmarks.create({
let createBookmark = browser.bookmarks.create({
url: "http://localhost:7657/i2psnark",
title: "Bittorrent",
parentId: bookmarkToolbar[0].id
});
createBookmark.then(onCreated);
} else {
var createBookmark = browser.bookmarks.create({
let createRhizomeBookmark = browser.bookmarks.create({
url:
"http://" + control_host + ":" + control_port + "/i2psnark",
title: "Bittorrent",
parentId: bookmarkToolbar[0].id
});
createBookmark.then(onCreated);
createRhizomeBookmark.then(onCreated);
}
}
console.log(
"(bookmarks) checking if we're running in an I2P Browser"
);
var gettingInfo = browser.proxy.settings.get({});
gettingInfo.then(gotProxyInfo);
let gettingProxyInfo = browser.proxy.settings.get({});
gettingProxyInfo.then(gotProxyInfo);
}
}
function bookMail(bookmarkItems) {
if (!bookmarkItems.length) {
function gotProxyInfo(info) {
let host = info.value.http.split(":")[0];
let port = info.value.http.split(":")[1];
if (port == "7644") {
var createBookmark = browser.bookmarks.create({
let createBookmark = browser.bookmarks.create({
url: "http://localhost:7657/webmail",
title: "Web Mail",
parentId: bookmarkToolbar[0].id
});
createBookmark.then(onCreated);
} else {
var createBookmark = browser.bookmarks.create({
let createRhizomeBookmark = browser.bookmarks.create({
url: "http://" + control_host + ":" + control_port + "/webmail",
title: "Web Mail",
parentId: bookmarkToolbar[0].id
});
createBookmark.then(onCreated);
createRhizomeBookmark.then(onCreated);
}
console.log("(bookmarks) adding webmail bookmark");
}
console.log(
"(bookmarks) checking if we're running in an I2P Browser"
);
var gettingInfo = browser.proxy.settings.get({});
gettingInfo.then(gotProxyInfo);
let gettingProxyInfo = browser.proxy.settings.get({});
gettingProxyInfo.then(gotProxyInfo);
}
}
function bookI2PTunnel(bookmarkItems) {
if (!bookmarkItems.length) {
function gotProxyInfo(info) {
let host = info.value.http.split(":")[0];
let port = info.value.http.split(":")[1];
if (port == "7644") {
var createBookmark = browser.bookmarks.create({
@@ -103,7 +99,7 @@ gettingInfo.then(got => {
});
createBookmark.then(onCreated);
} else {
var createBookmark = browser.bookmarks.create({
var createRhizomeBookmark = browser.bookmarks.create({
url:
"http://" +
control_host +
@@ -113,15 +109,15 @@ gettingInfo.then(got => {
title: "Hidden Services Manager",
parentId: bookmarkToolbar[0].id
});
createBookmark.then(onCreated);
createRhizomeBookmark.then(onCreated);
}
console.log("(bookmarks) adding i2ptunnel bookmark");
}
console.log(
"(bookmarks) checking if we're running in an I2P Browser"
);
var gettingInfo = browser.proxy.settings.get({});
gettingInfo.then(gotProxyInfo);
var gettingProxyInfo = browser.proxy.settings.get({});
gettingProxyInfo.then(gotProxyInfo);
}
}
@@ -160,9 +156,9 @@ gettingInfo.then(got => {
bt.then(bookmarks);
function handleCreated(id, bookmarkInfo) {
var propValue;
//var propValue;
for (var propName in bookmarkInfo) {
propValue = bookmarkInfo[propName];
let propValue = bookmarkInfo[propName];
console.log(propName, propValue);
}
}

View File

@@ -26,7 +26,7 @@ function eventHandler(event) {
cookieStoreId: event.target.dataset.identity
})
.then(tabs => {
browser.tabs.remove(tabs.map(i => i.id));
browser.tabs.remove(tabs.map(rem => rem.id));
});
}
event.preventDefault();
@@ -34,13 +34,13 @@ function eventHandler(event) {
function createOptions(node, identity) {
for (let option of ["Create", "Close All"]) {
let a = document.createElement("a");
a.href = "#";
a.innerText = option;
a.dataset.action = option.toLowerCase().replace(" ", "-");
a.dataset.identity = identity.cookieStoreId;
a.addEventListener("click", eventHandler);
node.appendChild(a);
let alink = document.createElement("a");
alink.href = "#";
alink.innerText = option;
alink.dataset.action = option.toLowerCase().replace(" ", "-");
alink.dataset.identity = identity.cookieStoreId;
alink.addEventListener("click", eventHandler);
node.appendChild(alink);
}
}

View File

@@ -26,9 +26,9 @@ function trimHost(url) {
return path;
}
var handlerSetup = async function(requestDetails) {
var handlerSetup = function(requestDetails) {
//console.log("checking protocol handler listener")
var rwurl = identifyProtocolHandler(requestDetails.url);
let rwurl = identifyProtocolHandler(requestDetails.url);
if (rwurl != false) {
console.log("(handler) rewrite URL requested", rwurl);
requestDetails.redirectUrl = rwurl;

22
home.js
View File

@@ -1,24 +1,24 @@
document.addEventListener("click", e => {
if (e.target.id === "onboardingButtonZero") {
document.addEventListener("click", clickEvent => {
if (clickEvent.target.id === "onboardingButtonZero") {
flipVisibility("onboardingContentZero");
} else if (e.target.id === "onboardingButtonOne") {
} else if (clickEvent.target.id === "onboardingButtonOne") {
flipVisibility("onboardingContentOne");
} else if (e.target.id === "onboardingButtonTwo") {
} else if (clickEvent.target.id === "onboardingButtonTwo") {
flipVisibility("onboardingContentTwo");
} else if (e.target.id === "onboardingButtonThree") {
} else if (clickEvent.target.id === "onboardingButtonThree") {
flipVisibility("onboardingContentThree");
} else if (e.target.id === "onboardingButtonFour") {
} else if (clickEvent.target.id === "onboardingButtonFour") {
flipVisibility("onboardingContentFour");
} else if (e.target.id === "fliplinks") {
} else if (clickEvent.target.id === "fliplinks") {
flipVisibility("info-content");
}
});
function flipVisibility(div) {
var x = document.getElementById(div);
if (x.style.display === "none") {
x.style.display = "block";
let flippable = document.getElementById(div);
if (flippable.style.display === "none") {
flippable.style.display = "block";
} else {
x.style.display = "none";
flippable.style.display = "none";
}
}

View File

@@ -77,11 +77,11 @@ function routerHost(url) {
}
if (url.indexOf("://") > -1) {
hostname = url.split("/")[2];
prefix = url.substr(0, url.indexOf("://") + 3);
let prefix = url.substr(0, url.indexOf("://") + 3);
path = url.replace(prefix + hostname + "/", "");
} else if (identifyProtocolHandler(url)) {
url = identifyProtocolHandler(url);
return routerHost(url);
let newurl = identifyProtocolHandler(url);
return routerHost(newurl);
} else {
hostname = url.split("/")[0];
path = url.replace(hostname + "/", "");

87
info.js
View File

@@ -1,7 +1,7 @@
function checkPeerConnection() {
var getting = browser.privacy.network.peerConnectionEnabled.get({});
let getting = browser.privacy.network.peerConnectionEnabled.get({});
getting.then(got => {
webrtc = got.value;
let webrtc = got.value;
console.log("checking webrtc", webrtc);
document.getElementById("enable-web-rtc").checked = webrtc;
});
@@ -10,9 +10,9 @@ function checkPeerConnection() {
checkPeerConnection();
function checkHistory() {
var getting = browser.storage.local.get("disable_history");
let getting = browser.storage.local.get("disable_history");
getting.then(got => {
disable_history = got.disable_history;
let disable_history = got.disable_history;
if (disable_history == undefined) {
disable_history = false;
}
@@ -23,8 +23,8 @@ function checkHistory() {
checkHistory();
document.addEventListener("click", e => {
if (e.target.id === "window-create-help-panel") {
document.addEventListener("click", clickEvent => {
if (clickEvent.target.id === "window-create-help-panel") {
let createData = {
type: "panel",
incognito: true
@@ -33,7 +33,7 @@ document.addEventListener("click", e => {
creating.then(() => {
console.log("The help panel has been created");
});
} else if (e.target.id === "window-create-news-panel") {
} else if (clickEvent.target.id === "window-create-news-panel") {
let createData = {
type: "panel",
incognito: true
@@ -42,54 +42,52 @@ document.addEventListener("click", e => {
creating.then(() => {
console.log("The news panel has been created");
});
} else if (e.target.id === "generate-fresh-tunnel") {
function RefreshIdentity() {
} else if (clickEvent.target.id === "generate-fresh-tunnel") {
function refreshIdentity() {
console.log("Generating new identity");
const Http = new XMLHttpRequest();
const url = "http://" + controlHost + ":" + controlPort;
Http.open("GET", url);
Http.send();
Http.onreadystatechange = e => {
Http.onreadystatechange = event => {
console.log(Http.responseText);
};
}
RefreshIdentity();
} else if (e.target.id === "window-preface-title") {
} else if (e.target.id === "window-visit-homepage") {
refreshIdentity();
} else if (clickEvent.target.id === "window-preface-title") {
} else if (clickEvent.target.id === "window-visit-homepage") {
console.log("attempting to create homepage tab");
goHome();
} else if (e.target.id === "window-visit-i2ptunnel") {
} else if (clickEvent.target.id === "window-visit-i2ptunnel") {
console.log("attempting to create i2ptunnel tab");
goTunnel();
} else if (e.target.id === "window-visit-susimail") {
} else if (clickEvent.target.id === "window-visit-susimail") {
console.log("attempting to create susimail tab");
goMail();
} else if (e.target.id === "window-visit-snark") {
} else if (clickEvent.target.id === "window-visit-snark") {
console.log("attempting to create snark tab");
goSnark();
} else if (e.target.id === "clear-browser-data") {
} else if (clickEvent.target.id === "clear-browser-data") {
forgetBrowsingData();
} else if (e.target.id === "check-i2p-control") {
echo("I2P Router Detected", "panel-section-i2pcontrol-check");
} else if (e.target.id === "enable-web-rtc") {
if (e.target.checked) {
} else if (clickEvent.target.id === "check-i2p-control") {
//echo("I2P Router Detected", "panel-section-i2pcontrol-check");
} else if (clickEvent.target.id === "enable-web-rtc") {
if (clickEvent.target.checked) {
browser.runtime.sendMessage({ rtc: "enableWebRTC" });
} else {
browser.runtime.sendMessage({ rtc: "disableWebRTC" });
}
//checkPeerConnection()
return;
} else if (e.target.id === "disable-history") {
if (e.target.checked) {
} else if (clickEvent.target.id === "disable-history") {
if (clickEvent.target.checked) {
browser.runtime.sendMessage({ history: "disableHistory" });
} else {
browser.runtime.sendMessage({ history: "enableHistory" });
}
//checkHistory()
return;
}
e.preventDefault();
clickEvent.preventDefault();
});
function proxyReadiness() {
@@ -105,14 +103,13 @@ gettingInfo.then(got => {
function goHome() {
function gotProxyInfo(info) {
let host = info.value.http.split(":")[0];
let port = info.value.http.split(":")[1];
if (port == "7644") {
let createData = {
let createRhizomeData = {
url: "about:I2p"
};
console.log("visiting homepage");
let creating = browser.tabs.create(createData);
let creating = browser.tabs.create(createRhizomeData);
} else {
let createData = {
url: "home.html"
@@ -123,40 +120,56 @@ function goHome() {
console.log("(bookmarks) adding home page bookmark");
}
console.log("(bookmarks) checking if we're running in an I2P Browser");
var gettingInfo = browser.proxy.settings.get({});
gettingInfo.then(gotProxyInfo);
var gettingProxyInfo = browser.proxy.settings.get({});
gettingProxyInfo.then(gotProxyInfo);
}
function onTabCreated() {
console.log("Tab Created");
}
function goTunnel() {
function onTabError() {
console.log("I2PTunnel tab created");
}
let createData = {
url: "http://" + control_host + ":" + control_port + "/i2ptunnel"
};
console.log("visiting homepage");
console.log("visiting i2ptunnel");
let creating = browser.tabs.create(createData);
creating(onTabCreated, onTabError);
}
function goMail() {
function onTabError() {
console.log("Mail tab created");
}
let createData = {
url: "http://" + control_host + ":" + control_port + "/susimail"
};
console.log("visiting homepage");
console.log("visiting mail");
let creating = browser.tabs.create(createData);
creating(onTabCreated, onTabError);
}
function goSnark() {
function onTabError() {
console.log("Snark tab created");
}
let createData = {
url: "http://" + control_host + ":" + control_port + "/i2psnark"
};
console.log("visiting homepage");
console.log("visiting snark");
let creating = browser.tabs.create(createData);
creating(onTabCreated, onTabError);
}
function onVisited(historyItem) {
function onCleaned(results) {
if (!results.length) {
console.log(" was removed");
} else {
if (results.length) {
console.log(" was not removed");
} else {
console.log(" was removed");
}
}

View File

@@ -1,17 +1,4 @@
var titlepref = chrome.i18n.getMessage("titlePreface");
var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate");
var webpref = chrome.i18n.getMessage("webPreface");
var webprefpriv = chrome.i18n.getMessage("webPrefacePrivate");
var routerpref = chrome.i18n.getMessage("routerPreface");
var routerprefpriv = chrome.i18n.getMessage("routerPrefacePrivate");
var mailpref = chrome.i18n.getMessage("mailPreface");
var mailprefpriv = chrome.i18n.getMessage("mailPrefacePrivate");
var torrentpref = chrome.i18n.getMessage("torrentPreface");
var torrentprefpriv = chrome.i18n.getMessage("torrentPrefacePrivate");
var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate");
var android; // = false;
var android = false;
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {

View File

@@ -1,13 +1,4 @@
var webpref = chrome.i18n.getMessage("webPreface");
var webprefpriv = chrome.i18n.getMessage("webPrefacePrivate");
var routerpref = chrome.i18n.getMessage("routerPreface");
var routerprefpriv = chrome.i18n.getMessage("routerPrefacePrivate");
var mailpref = chrome.i18n.getMessage("mailPreface");
var mailprefpriv = chrome.i18n.getMessage("mailPrefacePrivate");
var torrentpref = chrome.i18n.getMessage("torrentPreface");
var torrentprefpriv = chrome.i18n.getMessage("torrentPrefacePrivate");
var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate");
var titlepref = chrome.i18n.getMessage("titlePreface");
function onSet(result) {
if (result) {
@@ -158,7 +149,7 @@ function EnablePeerConnection() {
function SetupPeerConnection() {
var webrtc = true;
console.log("Pre-disabled WebRTC");
rtc = browser.privacy.network.peerConnectionEnabled.set({
let rtc = browser.privacy.network.peerConnectionEnabled.set({
value: webrtc
});
rtc.then(AssurePeerConnection);
@@ -211,17 +202,10 @@ var defaultSettings = {
dataTypes: ["downloads", "passwords", "formData", "localStorage", "history"]
};
var appSettings = {
since: "forever",
dataTypes: [""]
};
function onError(e) {
console.error(e);
function onError(therror) {
console.error(therror);
}
function clearCookiesContext(cookieStoreId) {}
function forgetBrowsingData(storedSettings) {
function getSince(selectedSince) {
if (selectedSince === "forever") {
@@ -261,7 +245,7 @@ function forgetBrowsingData(storedSettings) {
function deepCleanHistory(historyItems) {
console.log("Deep cleaning history");
for (item of historyItems) {
for (let item of historyItems) {
if (i2pHost(item.url)) {
browser.history.deleteUrl({
url: item.url
@@ -297,12 +281,12 @@ function forgetBrowsingData(storedSettings) {
.then(onContextGotLog);
console.log("cleared Local Storage");
contexts = browser.contextualIdentities.query({
let contexts = browser.contextualIdentities.query({
name: titlepref
});
function deepCleanCookies(cookies) {
for (cookie of cookies) {
for (let cookie of cookies) {
var removing = browser.cookies.remove({
firstPartyDomain: cookie.firstPartyDomain,
name: cookie.name,
@@ -314,7 +298,7 @@ function forgetBrowsingData(storedSettings) {
}
function deepCleanContext(cookieStoreIds) {
for (cookieStoreId of cookieStoreIds) {
for (let cookieStoreId of cookieStoreIds) {
var removing = browser.cookies.getAll({
firstPartyDomain: null,
storeId: cookieStoreId.cookieStoreId
@@ -356,7 +340,7 @@ function i2pHost(url) {
}
function onContextGotLog(contexts) {
if (contexts != null) {
if (contexts !== null) {
for (let context of contexts) {
console.log(context);
}
@@ -370,9 +354,9 @@ function enableHistory() {
storedSettings["disable_history"] = false;
console.log(storedSettings);
function enablehistory(settings) {
console.log("Store History:", storedSettings);
console.log("Store History:", settings);
}
var setting = browser.storage.local.set(storedSettings);
let setting = browser.storage.local.set(storedSettings);
setting.then(enablehistory);
}
const gettingStoredSettings = browser.storage.local.get();
@@ -384,7 +368,7 @@ function disableHistory() {
storedSettings["disable_history"] = true;
console.log(storedSettings);
function enablehistory(settings) {
console.log("Store History:", storedSettings);
console.log("Store History:", settings);
}
var setting = browser.storage.local.set(storedSettings);
setting.then(enablehistory);
@@ -393,19 +377,19 @@ function disableHistory() {
gettingStoredSettings.then(checkStoredSettings, onError);
}
function message(message) {
console.log(message);
if (message.rtc === "enableWebRTC") {
function message(recieved) {
console.log(recieved);
if (recieved.rtc === "enableWebRTC") {
console.log("enableWebRTC");
EnablePeerConnection();
} else if (message.rtc === "disableWebRTC") {
} else if (recieved.rtc === "disableWebRTC") {
console.log("disableWebRTC");
ResetPeerConnection();
}
if (message.history === "enableHistory") {
if (recieved.history === "enableHistory") {
console.log("enableHistory");
enableHistory();
} else if (message.history === "disableHistory") {
} else if (recieved.history === "disableHistory") {
console.log("disableHistory");
disableHistory();
}

View File

@@ -1,15 +1,7 @@
var titlepref = chrome.i18n.getMessage("titlePreface");
var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate");
var webpref = chrome.i18n.getMessage("webPreface");
var webprefpriv = chrome.i18n.getMessage("webPrefacePrivate");
var routerpref = chrome.i18n.getMessage("routerPreface");
var routerprefpriv = chrome.i18n.getMessage("routerPrefacePrivate");
var mailpref = chrome.i18n.getMessage("mailPreface");
var mailprefpriv = chrome.i18n.getMessage("mailPrefacePrivate");
var torrentpref = chrome.i18n.getMessage("torrentPreface");
var torrentprefpriv = chrome.i18n.getMessage("torrentPrefacePrivate");
var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate");
browser.privacy.network.peerConnectionEnabled.set({
value: false
@@ -112,7 +104,8 @@ var handleContextProxyRequest = async function(requestDetails) {
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
return context;
} catch (error) {
return; //"firefox-default";
console.error(error);
//return; //"firefox-default";
}
};
var tabGet = async function(tabId) {
@@ -149,9 +142,9 @@ var handleContextProxyRequest = async function(requestDetails) {
console.log("(proxy)Returning I2P Proxy", proxy);
return proxy;
}
proxy = {};
/*proxy = {};
console.log("(proxy)Returning unset Proxy", proxy);
return proxy;
return proxy;*/
}
} catch (error) {
console.log("(proxy)Not using I2P Proxy.", error);
@@ -167,19 +160,22 @@ var disable_history = false;
function SetupSettings() {
console.log("Initialising Settings");
function onSetupError() {
console.log("Settings initialization error");
}
//
function checkSchemeStoredSettings(storedSettings) {
if (storedSettings.proxy_scheme != undefined) {
proxy_scheme = storedSettings.proxy_scheme;
} else {
if (storedSettings.proxy_scheme === undefined) {
proxy_scheme = "http";
storedSettings.proxy_scheme = proxy_scheme;
} 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, onError);
gettingSchemeStoredSettings.then(checkSchemeStoredSettings, onSetupError);
//
function checkHostStoredSettings(storedSettings) {
@@ -193,7 +189,7 @@ function SetupSettings() {
setupProxy();
}
var gettingHostStoredSettings = browser.storage.local.get("proxy_host");
gettingHostStoredSettings.then(checkHostStoredSettings, onError);
gettingHostStoredSettings.then(checkHostStoredSettings, onSetupError);
//
function checkPortStoredSettings(storedSettings) {
@@ -207,7 +203,7 @@ function SetupSettings() {
setupProxy();
}
var gettingPortStoredSettings = browser.storage.local.get("proxy_port");
gettingPortStoredSettings.then(checkPortStoredSettings, onError);
gettingPortStoredSettings.then(checkPortStoredSettings, onSetupError);
//
function checkControlHostStoredSettings(storedSettings) {
@@ -225,16 +221,16 @@ function SetupSettings() {
);
gettingControlHostStoredSettings.then(
checkControlHostStoredSettings,
onError
onSetupError
);
//
function checkControlPortStoredSettings(storedSettings) {
if (storedSettings.control_port != undefined) {
contro_port = storedSettings.control_port;
let control_port = storedSettings.control_port;
} else {
control_port = "7657";
storedSettings.control_port = control_port;
let new_control_port = "7657";
storedSettings.control_port = new_control_port;
}
console.log("Initialising Control Port", storedSettings.control_port);
setupProxy();
@@ -244,7 +240,7 @@ function SetupSettings() {
);
gettingControlPortStoredSettings.then(
checkControlPortStoredSettings,
onError
onSetupError
);
//
@@ -264,7 +260,7 @@ function SetupSettings() {
var gettingHistoryStoredSettings = browser.storage.local.get(
"disable_history"
);
gettingHistoryStoredSettings.then(checkHistoryStoredSettings, onError);
gettingHistoryStoredSettings.then(checkHistoryStoredSettings, onSetupError);
}
function getScheme() {
@@ -341,13 +337,13 @@ function updateFromStorage() {
gettingInfo.then(got => {
if (got.os != "android") {
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
chrome.storage.local.get(function(got) {
chrome.storage.local.get(function() {
SetupSettings();
update();
setupProxy();
});
} else {
chrome.storage.local.get(function(got) {
chrome.storage.local.get(function() {
SetupSettings();
update();
setupProxy();

191
scrub.js
View File

@@ -1,26 +1,22 @@
var titlepref = chrome.i18n.getMessage("titlePreface");
var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate");
var webpref = chrome.i18n.getMessage("webPreface");
var webprefpriv = chrome.i18n.getMessage("webPrefacePrivate");
var routerpref = chrome.i18n.getMessage("routerPreface");
var routerprefpriv = chrome.i18n.getMessage("routerPrefacePrivate");
var mailpref = chrome.i18n.getMessage("mailPreface");
var mailprefpriv = chrome.i18n.getMessage("mailPrefacePrivate");
var torrentpref = chrome.i18n.getMessage("torrentPreface");
var torrentprefpriv = chrome.i18n.getMessage("torrentPrefacePrivate");
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 contextScrub = async function(requestDetails) {
function onHeaderError() {
console.log("Header scrub error");
}
console.log("(scrub)Scrubbing info from contextualized request");
try {
var headerScrub = function(context) {
var ua = "MYOB/6.66 (AN/ON)";
if (!context) {
console.log("Context not found", context);
} else if (context.name == titlepref) {
var ua = "MYOB/6.66 (AN/ON)";
if (i2pHost(requestDetails.url)) {
for (var header of requestDetails.requestHeaders) {
if (header.name.toLowerCase() === "user-agent") {
@@ -33,7 +29,6 @@ var contextScrub = async function(requestDetails) {
requestHeaders: requestDetails.requestHeaders
};
} else if (context.name == routerpref) {
var ua = "MYOB/6.66 (AN/ON)";
if (i2pHost(requestDetails.url)) {
for (var header of requestDetails.requestHeaders) {
if (header.name.toLowerCase() === "user-agent") {
@@ -41,7 +36,6 @@ var contextScrub = async function(requestDetails) {
console.log("(scrub)User-Agent header modified", header.value);
}
}
} else if (routerHost(requestDetails.url)) {
}
return {
requestHeaders: requestDetails.requestHeaders
@@ -75,14 +69,14 @@ var contextScrub = async function(requestDetails) {
if (i2pHost(requestDetails.url)) {
console.log("(scrub)I2P URL detected, ");
tab = tabGet(requestDetails.tabId);
context = tab.then(contextGet, onError);
req = await context.then(headerScrub, onError);
context = tab.then(contextGet, onHeaderError);
req = await context.then(headerScrub, onHeaderError);
console.log("(scrub)Scrubbing I2P Request", req);
return req;
} else if (routerHost(requestDetails.url)) {
tab = tabGet(requestDetails.tabId);
context = tab.then(contextGet, onError);
req = await context.then(headerScrub, onError);
context = tab.then(contextGet, onHeaderError);
req = await context.then(headerScrub, onHeaderError);
console.log("(scrub)Scrubbing non-I2P Request", req);
return req;
}
@@ -94,6 +88,9 @@ var contextScrub = async function(requestDetails) {
};
var contextSetup = async function(requestDetails) {
function onContextError() {
console.log("Context launcher error");
}
console.log("(isolate)Forcing I2P requests into context");
try {
var i2pTabFind = async function(tabId) {
@@ -104,16 +101,14 @@ var contextSetup = async function(requestDetails) {
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create(currentTab) {
function Create() {
function onCreated(tab) {
function closeOldTab(tab) {
if (!notClosable()) {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
function closeOldTab() {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
}
closeOldTab(tab);
@@ -123,10 +118,10 @@ var contextSetup = async function(requestDetails) {
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url
});
created.then(onCreated, onError);
created.then(onCreated, onContextError);
}
var gettab = browser.tabs.get(tabId.id);
gettab.then(Create, onError);
gettab.then(Create, onContextError);
return tabId;
}
} catch (error) {
@@ -141,16 +136,14 @@ var contextSetup = async function(requestDetails) {
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create(currentTab) {
function Create() {
function onCreated(tab) {
function closeOldTab(tab) {
if (!notClosable()) {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
function closeOldTab() {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
}
closeOldTab(tab);
@@ -160,10 +153,10 @@ var contextSetup = async function(requestDetails) {
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url
});
created.then(onCreated, onError);
created.then(onCreated, onContextError);
}
var gettab = browser.tabs.get(tabId.id);
gettab.then(Create, onError);
gettab.then(Create, onContextError);
return tabId;
}
} catch (error) {
@@ -178,16 +171,14 @@ var contextSetup = async function(requestDetails) {
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create(currentTab) {
function Create() {
function onCreated(tab) {
function closeOldTab(tab) {
if (!notClosable()) {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
function closeOldTab() {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
}
closeOldTab(tab);
@@ -197,10 +188,10 @@ var contextSetup = async function(requestDetails) {
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url
});
created.then(onCreated, onError);
created.then(onCreated, onContextError);
}
var gettab = browser.tabs.get(tabId.id);
gettab.then(Create, onError);
gettab.then(Create, onContextError);
return tabId;
}
} catch (error) {
@@ -215,16 +206,14 @@ var contextSetup = async function(requestDetails) {
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create(currentTab) {
function Create() {
function onCreated(tab) {
function closeOldTab(tab) {
if (!notClosable()) {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
function closeOldTab() {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
}
closeOldTab(tab);
@@ -234,10 +223,10 @@ var contextSetup = async function(requestDetails) {
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url
});
created.then(onCreated, onError);
created.then(onCreated, onContextError);
}
var gettab = browser.tabs.get(tabId.id);
gettab.then(Create, onError);
gettab.then(Create, onContextError);
return tabId;
}
} catch (error) {
@@ -252,16 +241,14 @@ var contextSetup = async function(requestDetails) {
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create(currentTab) {
function Create() {
function onCreated(tab) {
function closeOldTab(tab) {
if (!notClosable()) {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
function closeOldTab() {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
}
closeOldTab(tab);
@@ -271,10 +258,10 @@ var contextSetup = async function(requestDetails) {
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url
});
created.then(onCreated, onError);
created.then(onCreated, onContextError);
}
var gettab = browser.tabs.get(tabId.id);
gettab.then(Create, onError);
gettab.then(Create, onContextError);
return tabId;
}
} catch (error) {
@@ -289,16 +276,14 @@ var contextSetup = async function(requestDetails) {
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create(currentTab) {
function Create() {
function onCreated(tab) {
function closeOldTab(tab) {
if (!notClosable()) {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
function closeOldTab() {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
}
closeOldTab(tab);
@@ -308,10 +293,10 @@ var contextSetup = async function(requestDetails) {
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url
});
created.then(onCreated, onError);
created.then(onCreated, onContextError);
}
var gettab = browser.tabs.get(tabId.id);
gettab.then(Create, onError);
gettab.then(Create, onContextError);
return tabId;
}
} catch (error) {
@@ -331,17 +316,14 @@ var contextSetup = async function(requestDetails) {
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create(currentTab) {
function Create() {
function onCreated(tab) {
function closeOldTab(tab) {
if (!notClosable()) {
if (tabId.id != tab.id) {
let o = tabId.id;
console.log("(isolate) Closing un-isolated tab", o);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
function closeOldTab() {
if (tabId.id != tab.id) {
console.log("(isolate) Closing un-isolated tab", tabId.id);
console.log("in favor of", tab.id);
console.log("with context", tab.cookieStoreId);
browser.tabs.remove(tabId.id);
}
}
closeOldTab(tab);
@@ -351,10 +333,10 @@ var contextSetup = async function(requestDetails) {
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url
});
created.then(onCreated, onError);
created.then(onCreated, onContextError);
}
var gettab = browser.tabs.get(tabId.id);
gettab.then(Create, onError);
gettab.then(Create, onContextError);
return tabId;
}
}
@@ -381,13 +363,12 @@ var contextSetup = async function(requestDetails) {
url: requestDetails.url,
secure: true
});
setcookie.then(onContextGotLog, onError);
setcookie.then(onContextGotLog, onContextError);
return requestDetails;
}
console.log("(isolate)Request Details", requestDetails);
var tab = tabGet(requestDetails.tabId);
if (extensionHost(requestDetails.url)) {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(anyTabFind, onError);
return requestDetails;
}
if (i2pHost(requestDetails.url)) {
@@ -396,36 +377,30 @@ var contextSetup = async function(requestDetails) {
url: requestDetails.url,
secure: true
});
setcookie.then(onContextGotLog, onError);
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(i2pTabFind, onError);
setcookie.then(onContextGotLog, onContextError);
var i2ptab = tab.then(i2pTabFind, onContextError);
return requestDetails;
}
let localhost = localHost(requestDetails.url);
let routerhost = routerHost(requestDetails.url);
if (!routerhost) {
if (localhost) {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(localTabFind, onError);
var localtab = tab.then(localTabFind, onContextError);
return requestDetails;
}
}
if (routerhost) {
if (routerhost === "i2ptunnelmgr") {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(i2ptunnelTabFind, onError);
var tunneltab = tab.then(i2ptunnelTabFind, onContextError);
return requestDetails;
} else if (routerhost === "i2psnark") {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(snarkTabFind, onError);
var snarktab = tab.then(snarkTabFind, onContextError);
return requestDetails;
} else if (routerhost === "webmail") {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(mailTabFind, onError);
var mailtab = tab.then(mailTabFind, onContextError);
return requestDetails;
} else if (routerhost === "routerconsole") {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(routerTabFind, onError);
var routertab = tab.then(routerTabFind, onContextError);
return requestDetails;
}
} else {