From 994b021a955930a3ab71a09d4ee5c7009a557d1c Mon Sep 17 00:00:00 2001 From: idk Date: Tue, 5 Nov 2019 22:09:41 -0500 Subject: [PATCH 1/3] start messing with bookmarks and stuff --- background.js | 1 + manifest.json | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index d1320e4..2caba8e 100644 --- a/background.js +++ b/background.js @@ -165,3 +165,4 @@ chrome.tabs.onCreated.addListener(() => { }); getting.then(setTitle, onError); }); + diff --git a/manifest.json b/manifest.json index ae2b250..d60a04a 100644 --- a/manifest.json +++ b/manifest.json @@ -5,9 +5,13 @@ "strict_min_version": "60.0" } }, + "chrome_settings_overrides": { + "homepage": "home.html" + }, "permissions": [ "theme", "browsingData", + "bookmarks", "notifications", "proxy", "privacy", @@ -45,7 +49,8 @@ "proxy.js", "info.js", "i2pcontrol.js", - "scrub.js" + "scrub.js", + "bookmarks.js" ] }, "protocol_handlers": [{ From 38d5dcb929ff12f4cea287486a565b64f24e339d Mon Sep 17 00:00:00 2001 From: idk Date: Tue, 5 Nov 2019 22:11:00 -0500 Subject: [PATCH 2/3] start messing with bookmarks and stuff --- background.js | 1 - 1 file changed, 1 deletion(-) diff --git a/background.js b/background.js index 2caba8e..d1320e4 100644 --- a/background.js +++ b/background.js @@ -165,4 +165,3 @@ chrome.tabs.onCreated.addListener(() => { }); getting.then(setTitle, onError); }); - From 33cfbc324a14bec483efb750ae28ba595d85434e Mon Sep 17 00:00:00 2001 From: idk Date: Sun, 10 Nov 2019 20:28:31 -0500 Subject: [PATCH 3/3] update color schemes, blackhole non-routerconsole URL's on the localhost --- .gitignore | 2 +- Makefile | 12 ++ background.js | 35 +++-- chromium/browser-polyfill.js | 148 ++++++++++------------ context.js | 25 ++-- i2pcontrol.js => i2pcontrol/i2pcontrol.js | 10 +- privacy.js | 34 ++--- proxy.js | 57 +++++++-- scrub.js | 70 +++++----- window.html | 1 - 10 files changed, 227 insertions(+), 167 deletions(-) rename i2pcontrol.js => i2pcontrol/i2pcontrol.js (82%) diff --git a/.gitignore b/.gitignore index 3a75765..94e387d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ README.md.asc - +node_modules/ diff --git a/Makefile b/Makefile index 8821ec1..2bd1915 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,15 @@ VERSION=0.41 #VERSION=$(MOZ_VERSION) #VERSION=1.27 +YELLOW=F7E59A +ORANGE=FFC56D +GREY=D9D9D6 +BLUE=A4C8E1 +PURPLE=A48fE1 + +colors: + @echo " yellow $(YELLOW) \n orange $(ORANGE) \n grey $(GREY) \n blue $(BLUE) \n purple $(PURPLE)" + amo-readme: markdown README.md | \ sed 's|

||g' | \ @@ -91,6 +100,9 @@ libpolyfill: fmt: find . -path ./node_modules -prune -o -name '*.js' -exec prettier --write {} \; +lint: + eslint --fix *.js + deborig: rm -rf ../i2psetproxy.js-$(VERSION) cp -r . ../i2psetproxy.js-$(VERSION) diff --git a/background.js b/background.js index d1320e4..19cd056 100644 --- a/background.js +++ b/background.js @@ -9,7 +9,7 @@ function onGot(contexts) { browser.contextualIdentities .create({ name: "i2pbrowser", - color: "purple", + color: "orange", icon: "fingerprint" }) .then(onCreated, onError); @@ -18,7 +18,7 @@ function onGot(contexts) { browser.contextualIdentities .create({ name: "routerconsole", - color: "turquoise", + color: "blue", icon: "briefcase" }) .then(onCreated, onError); @@ -68,15 +68,15 @@ function themeWindow(window) { if (window.incognito) { chrome.theme.update(window.id, { colors: { - frame: "#2D4470", - toolbar: "#2D4470" + frame: "#FFC56D", + toolbar: "#FFC56D" } }); } else { chrome.theme.update(window.id, { colors: { - frame: "#9DABD5", - toolbar: "#9DABD5" + frame: "#FFC56D", + toolbar: "#FFC56D" } }); } @@ -85,15 +85,15 @@ function themeWindow(window) { if (window.incognito) { chrome.theme.update(window.id, { colors: { - frame: "#00CED1", - toolbar: "#00CED1" + frame: "#A4C8E1", + toolbar: "#A4C8E1" } }); } else { chrome.theme.update(window.id, { colors: { - frame: "#40E0D0", - toolbar: "#40E0D0" + frame: "#A4C8E1", + toolbar: "#A4C8E1" } }); } @@ -101,7 +101,10 @@ function themeWindow(window) { console.log("Not active in I2P window"); } } - if (tabInfo[0].cookieStoreId != "firefox-default") { + if ( + tabInfo[0].cookieStoreId != "firefox-default" && + tabInfo[0].cookieStoreId != "firefox-private" + ) { browser.contextualIdentities .get(tabInfo[0].cookieStoreId) .then(onGot, onError); @@ -138,10 +141,14 @@ function setTitle(window) { } } - if (tabInfo[0].cookieStoreId != "firefox-default") + if ( + tabInfo[0].cookieStoreId != "firefox-default" && + tabInfo[0].cookieStoreId != "firefox-private" + ) { browser.contextualIdentities .get(tabInfo[0].cookieStoreId) .then(onGot, onError); + } } var querying = browser.tabs.query({ @@ -152,8 +159,8 @@ function setTitle(window) { } chrome.windows.onCreated.addListener(() => { - //var gettingStoredSettings = chrome.storage.local.get(); - //gettingStoredSettings.then(setupProxy, onError); + /* var gettingStoredSettings = chrome.storage.local.get(); + gettingStoredSettings.then(setupProxy, onError); */ chrome.storage.local.get(function(got) { setupProxy(); }); diff --git a/chromium/browser-polyfill.js b/chromium/browser-polyfill.js index fe479cb..36d18b9 100644 --- a/chromium/browser-polyfill.js +++ b/chromium/browser-polyfill.js @@ -17,6 +17,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + "use strict"; if ( @@ -28,15 +29,15 @@ const SEND_RESPONSE_DEPRECATION_WARNING = "Returning a Promise is the preferred way to send a reply from an onMessage/onMessageExternal listener, as the sendResponse will be removed from the specs (See https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage)"; - // Wrapping the bulk of this polyfill in a one-time-use function is a minor - // optimization for Firefox. Since Spidermonkey does not fully parse the - // contents of a function until the first time it's called, and since it will - // never actually need to be called, this allows the polyfill to be included - // in Firefox nearly for free. + /* Wrapping the bulk of this polyfill in a one-time-use function is a minor + optimization for Firefox. Since Spidermonkey does not fully parse the + contents of a function until the first time it's called, and since it will + never actually need to be called, this allows the polyfill to be included + in Firefox nearly for free. */ const wrapAPIs = extensionAPIs => { - // NOTE: apiMetadata is associated to the content of the api-metadata.json file - // at build time by replacing the following "include" with the content of the - // JSON file. + /* NOTE: apiMetadata is associated to the content of the api-metadata.json file + at build time by replacing the following "include" with the content of the + JSON file. */ const apiMetadata = { alarms: { clear: { @@ -734,12 +735,8 @@ * @param {*} value The value to test. * @returns {boolean} True if the value is thenable. */ - const isThenable = value => { - return ( - value && typeof value === "object" && typeof value.then === "function" - ); - }; - + const isThenable = value => + value && typeof value === "object" && typeof value.then === "function"; /** * Creates and returns a function which, when called, will resolve or reject * the given promise based on how it is called: @@ -767,19 +764,17 @@ * @returns {function} * The generated callback function. */ - const makeCallback = (promise, metadata) => { - return (...callbackArgs) => { - if (extensionAPIs.runtime.lastError) { - promise.reject(extensionAPIs.runtime.lastError); - } else if ( - metadata.singleCallbackArg || - (callbackArgs.length <= 1 && metadata.singleCallbackArg !== false) - ) { - promise.resolve(callbackArgs[0]); - } else { - promise.resolve(callbackArgs); - } - }; + const makeCallback = (promise, metadata) => (...callbackArgs) => { + if (extensionAPIs.runtime.lastError) { + promise.reject(extensionAPIs.runtime.lastError); + } else if ( + metadata.singleCallbackArg || + (callbackArgs.length <= 1 && metadata.singleCallbackArg !== false) + ) { + promise.resolve(callbackArgs[0]); + } else { + promise.resolve(callbackArgs); + } }; const pluralizeArguments = numArgs => @@ -807,8 +802,8 @@ * @returns {function(object, ...*)} * The generated wrapper function. */ - const wrapAsyncFunction = (name, metadata) => { - return function asyncFunctionWrapper(target, ...args) { + const wrapAsyncFunction = (name, metadata) => + function asyncFunctionWrapper(target, ...args) { if (args.length < metadata.minArgs) { throw new Error( `Expected at least ${metadata.minArgs} ${pluralizeArguments( @@ -827,9 +822,9 @@ return new Promise((resolve, reject) => { if (metadata.fallbackToNoCallback) { - // This API method has currently no callback on Chrome, but it return a promise on Firefox, - // and so the polyfill will try to call it with a callback first, and it will fallback - // to not passing the callback if the first call fails. + /* This API method has currently no callback on Chrome, but it return a promise on Firefox, + and so the polyfill will try to call it with a callback first, and it will fallback + to not passing the callback if the first call fails. */ try { target[name]( ...args, @@ -844,8 +839,8 @@ target[name](...args); - // Update the API method metadata, so that the next API calls will not try to - // use the unsupported callback anymore. + /* Update the API method metadata, so that the next API calls will not try to + use the unsupported callback anymore. */ metadata.fallbackToNoCallback = false; metadata.noCallback = true; @@ -862,7 +857,6 @@ } }); }; - }; /** * Wraps an existing method of the target object, so that calls to it are @@ -883,13 +877,12 @@ * A Proxy object for the given method, which invokes the given wrapper * method in its place. */ - const wrapMethod = (target, method, wrapper) => { - return new Proxy(method, { + const wrapMethod = (target, method, wrapper) => + new Proxy(method, { apply(targetMethod, thisObj, args) { return wrapper.call(thisObj, target, ...args); } }); - }; let hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty); @@ -935,20 +928,20 @@ let value = target[prop]; if (typeof value === "function") { - // This is a method on the underlying object. Check if we need to do - // any wrapping. + /* This is a method on the underlying object. Check if we need to do + any wrapping. */ if (typeof wrappers[prop] === "function") { // We have a special-case wrapper for this method. value = wrapMethod(target, target[prop], wrappers[prop]); } else if (hasOwnProperty(metadata, prop)) { - // This is an async method that we have metadata for. Create a - // Promise wrapper for it. + /* This is an async method that we have metadata for. Create a + Promise wrapper for it. */ let wrapper = wrapAsyncFunction(prop, metadata[prop]); value = wrapMethod(target, target[prop], wrapper); } else { - // This is a method that we don't know or care about. Return the - // original method, bound to the underlying object. + /* This is a method that we don't know or care about. Return the + original method, bound to the underlying object. */ value = value.bind(target); } } else if ( @@ -956,13 +949,13 @@ value !== null && (hasOwnProperty(wrappers, prop) || hasOwnProperty(metadata, prop)) ) { - // This is an object that we need to do some wrapping for the children - // of. Create a sub-object wrapper for it with the appropriate child - // metadata. + /* This is an object that we need to do some wrapping for the children + of. Create a sub-object wrapper for it with the appropriate child + metadata. */ value = wrapObject(value, wrappers[prop], metadata[prop]); } else { - // We don't need to do any wrapping for this property, - // so just forward all access to the underlying object. + /* We don't need to do any wrapping for this property, + so just forward all access to the underlying object. */ Object.defineProperty(cache, prop, { configurable: true, enumerable: true, @@ -999,16 +992,15 @@ } }; - // Per contract of the Proxy API, the "get" proxy handler must return the - // original value of the target if that value is declared read-only and - // non-configurable. For this reason, we create an object with the - // prototype set to `target` instead of using `target` directly. - // Otherwise we cannot return a custom object for APIs that - // are declared read-only and non-configurable, such as `chrome.devtools`. - // - // The proxy handlers themselves will still use the original `target` - // instead of the `proxyTarget`, so that the methods and properties are - // dereferenced via the original targets. + /* Per contract of the Proxy API, the "get" proxy handler must return the + original value of the target if that value is declared read-only and + non-configurable. For this reason, we create an object with the + prototype set to `target` instead of using `target` directly. + Otherwise we cannot return a custom object for APIs that + are declared read-only and non-configurable, such as `chrome.devtools`. + The proxy handlers themselves will still use the original `target` + instead of the `proxyTarget`, so that the methods and properties are + dereferenced via the original targets. */ let proxyTarget = Object.create(target); return new Proxy(proxyTarget, handlers); }; @@ -1095,17 +1087,17 @@ const isResultThenable = result !== true && isThenable(result); - // If the listener didn't returned true or a Promise, or called - // wrappedSendResponse synchronously, we can exit earlier - // because there will be no response sent from this listener. + /* If the listener didn't returned true or a Promise, or called + wrappedSendResponse synchronously, we can exit earlier + because there will be no response sent from this listener. */ if (result !== true && !isResultThenable && !didCallSendResponse) { return false; } - // A small helper to send the message if the promise resolves - // and an error if the promise rejects (a wrapped sendMessage has - // to translate the message into a resolved promise or a rejected - // promise). + /* A small helper to send the message if the promise resolves + and an error if the promise rejects (a wrapped sendMessage has + to translate the message into a resolved promise or a rejected + promise). */ const sendPromisedResult = promise => { promise .then( @@ -1114,8 +1106,8 @@ sendResponse(msg); }, error => { - // Send a JSON representation of the error if the rejected value - // is an instance of error, or the object itself otherwise. + /* Send a JSON representation of the error if the rejected value + is an instance of error, or the object itself otherwise. */ let message; if ( error && @@ -1139,9 +1131,9 @@ }); }; - // If the listener returned a Promise, send the resolved value as a - // result, otherwise wait the promise related to the wrappedSendResponse - // callback to resolve and send it as a response. + /* If the listener returned a Promise, send the resolved value as a + result, otherwise wait the promise related to the wrappedSendResponse + callback to resolve and send it as a response. */ if (isResultThenable) { sendPromisedResult(result); } else { @@ -1155,9 +1147,9 @@ const wrappedSendMessageCallback = ({ reject, resolve }, reply) => { if (extensionAPIs.runtime.lastError) { - // Detect when none of the listeners replied to the sendMessage call and resolve - // the promise to undefined as in Firefox. - // See https://github.com/mozilla/webextension-polyfill/issues/130 + /* Detect when none of the listeners replied to the sendMessage call and resolve + the promise to undefined as in Firefox. + See https://github.com/mozilla/webextension-polyfill/issues/130 */ if ( extensionAPIs.runtime.lastError.message === CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE @@ -1167,8 +1159,8 @@ reject(extensionAPIs.runtime.lastError); } } else if (reply && reply.__mozWebExtensionPolyfillReject__) { - // Convert back the JSON representation of the error into - // an Error instance. + /* Convert back the JSON representation of the error into + an Error instance. */ reject(new Error(reply.message)); } else { resolve(reply); @@ -1251,8 +1243,8 @@ ); } - // The build process adds a UMD wrapper around this file, which makes the - // `module` variable available. + /* The build process adds a UMD wrapper around this file, which makes the + `module` variable available. */ module.exports = wrapAPIs(chrome); } else { module.exports = browser; diff --git a/context.js b/context.js index aa6428e..7d1a100 100644 --- a/context.js +++ b/context.js @@ -1,19 +1,20 @@ //var windowIds = [] +function onCreated(windowInfo) { + console.log(`Created window: ${windowInfo.id}`); + browser.tabs.create({ + windowId: windowInfo.id, + url: "about:blank", + cookieStoreId: event.target.dataset.identity + }); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + function eventHandler(event) { if (event.target.dataset.action == "create") { - function onCreated(windowInfo) { - console.log(`Created window: ${windowInfo.id}`); - browser.tabs.create({ - windowId: windowInfo.id, - url: "about:blank", - cookieStoreId: event.target.dataset.identity - }); - } - - function onError(error) { - console.log(`Error: ${error}`); - } var creating = browser.windows.create({ cookieStoreId: event.target.dataset.identity }); diff --git a/i2pcontrol.js b/i2pcontrol/i2pcontrol.js similarity index 82% rename from i2pcontrol.js rename to i2pcontrol/i2pcontrol.js index c56ce2c..622e80d 100644 --- a/i2pcontrol.js +++ b/i2pcontrol/i2pcontrol.js @@ -4,7 +4,7 @@ function send(json) { const url = "http://" + "127.0.0.1" + ":" + "7650"; Http.open("POST", url); Http.send(json); - console.log(Http); + //console.log(Http); return Http; } @@ -21,11 +21,12 @@ function authenticate(user, password) { return send(json); } -username = ""; -password = ""; +var username = ""; +var password = ""; function echo(string, section) { var xhr = authenticate(username, password); + console.log("(i2pcontrol) echo", xhr); xhr.onload = function() { resp = JSON.Parse(xhr.responseText); json = { @@ -38,6 +39,9 @@ function echo(string, section) { } }; var controlMessage = document.getElementById(section); + console.log("(i2pcontrol) reply", xhr.responseText); infoMessage.textContent = xhr.responseText; }; } + +echo("test", "test"); diff --git a/privacy.js b/privacy.js index a339834..b2d9e54 100644 --- a/privacy.js +++ b/privacy.js @@ -6,8 +6,8 @@ function onSet(result) { } } -// This disables queries to centralized databases of bad URLs to screen for -// risky sites in your browser +/* This disables queries to centralized databases of bad URLs to screen for + risky sites in your browser */ function disableHyperlinkAuditing() { var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({ value: false @@ -29,9 +29,9 @@ function enableFirstPartyIsolation() { setting.then(onSet); } -// This rejects tracking cookies and third-party cookies but it -// LEAVES "Persistent" Cookies unmodified in favor of an option in the content -// interface for now +/* This rejects tracking cookies and third-party cookies but it + LEAVES "Persistent" Cookies unmodified in favor of an option in the content + interface for now */ function disableEvilCookies() { var getting = browser.privacy.websites.cookieConfig.get({}); getting.then(got => { @@ -95,8 +95,8 @@ function enableTrackingProtection() { setting.then(onSet); } -// This disables protected content, which is a form of digital restrictions -// management dependent on identifying information +/* This disables protected content, which is a form of digital restrictions + management dependent on identifying information */ function disableDigitalRestrictionsManagement() { var gettingInfo = browser.runtime.getPlatformInfo(); gettingInfo.then(got => { @@ -201,15 +201,9 @@ function forgetBrowsingData(storedSettings) { } const times = { - hour: () => { - return 1000 * 60 * 60; - }, - day: () => { - return 1000 * 60 * 60 * 24; - }, - week: () => { - return 1000 * 60 * 60 * 24 * 7; - } + hour: () => 1000 * 60 * 60, + day: () => 1000 * 60 * 60 * 24, + week: () => 1000 * 60 * 60 * 24 * 7 }; const sinceMilliseconds = times[selectedSince].call(); @@ -249,28 +243,28 @@ function forgetBrowsingData(storedSettings) { browser.browsingData .removePasswords({ hostnames: [i2pHostName(item.url)], - since: since + since }) .then(onGot); console.log("cleared Passwords"); browser.browsingData .removeDownloads({ hostnames: [i2pHostName(item.url)], - since: since + since }) .then(onGot); console.log("cleared Downloads"); browser.browsingData .removeFormData({ hostnames: [i2pHostName(item.url)], - since: since + since }) .then(onGot); console.log("cleared Form Data"); browser.browsingData .removeLocalStorage({ hostnames: [i2pHostName(item.url)], - since: since + since }) .then(onGot); console.log("cleared Local Storage"); diff --git a/proxy.js b/proxy.js index 6b4d8cb..95c8302 100644 --- a/proxy.js +++ b/proxy.js @@ -20,22 +20,61 @@ var handleContextProxyRequest = async function(requestDetails) { var handleProxyRequest = function(context) { proxy = { failoverTimeout: 0, - type: "direct", proxyDns: false }; - if (context.name == "i2pbrowser") { + if (context != undefined) { + if (context.name == "i2pbrowser") { + proxy = { + type: getScheme(), + host: getHost(), + port: getPort() + }; + console.log( + "(proxy)", + context.name, + "Using", + proxy.type, + "proxy ", + proxy.host + ":" + proxy.port + ); + return proxy; + } else if (context.name == "routerconsole") { + if (i2pHost(requestDetails.url)) { + proxy = { + type: getScheme(), + host: getHost(), + port: getPort() + }; + } else if (!routerHost(requestDetails.url)) { + proxy = { + type: "http", + host: "localhost", + port: "1" + }; + } + console.log( + "(proxy)", + context.name, + "Using", + proxy.type, + "proxy ", + proxy.host + ":" + proxy.port + ); + return proxy; + } + } + if (i2pHost(requestDetails.url)) { proxy = { type: getScheme(), host: getHost(), port: getPort() }; - console.log( - "(proxy)Using", - proxy.type, - "proxy ", - proxy.host + ":" + proxy.port - ); - return proxy; + } else if (!routerHost(requestDetails.url)) { + proxy = { + type: "http", + host: "localhost", + port: "1" + }; } return proxy; }; diff --git a/scrub.js b/scrub.js index 424f9e5..71569c9 100644 --- a/scrub.js +++ b/scrub.js @@ -4,21 +4,33 @@ var contextScrub = async function(requestDetails) { var headerScrub = function(context) { if (!context) { console.error("Context not found"); - } else { - if ((context.name = "i2pbrowser")) { - var ua = "MYOB/6.66 (AN/ON)"; - if (i2pHost(requestUrl.url)) { - for (var header of requestDetails.requestHeaders) { - if (header.name.toLowerCase() === "user-agent") { - header.value = ua; - console.log("(scrub)User-Agent header modified", header.value); - } + } else if (context.name == "i2pbrowser") { + var ua = "MYOB/6.66 (AN/ON)"; + if (i2pHost(requestDetails.url)) { + for (var header of requestDetails.requestHeaders) { + if (header.name.toLowerCase() === "user-agent") { + header.value = ua; + console.log("(scrub)User-Agent header modified", header.value); } } - return { - requestHeaders: requestDetails.requestHeaders - }; } + return { + requestHeaders: requestDetails.requestHeaders + }; + } else if (context.name == "routerconsole") { + var ua = "MYOB/6.66 (AN/ON)"; + if (i2pHost(requestDetails.url)) { + for (var header of requestDetails.requestHeaders) { + if (header.name.toLowerCase() === "user-agent") { + header.value = ua; + console.log("(scrub)User-Agent header modified", header.value); + } + } + } else if (routerHost(requestDetails.url)) { + } + return { + requestHeaders: requestDetails.requestHeaders + }; } }; var contextGet = async function(tabInfo) { @@ -52,19 +64,22 @@ var contextScrub = async function(requestDetails) { } }; if (requestDetails.tabId > 0) { + var tab = {}; + var context = {}; + var req = {}; if (i2pHost(requestDetails.url)) { console.log("(Proxy)I2P URL detected, "); - var tab = tabGet(requestDetails.tabId); + tab = tabGet(requestDetails.tabId); var mtab = tab.then(tabFind); requestDetails.tabId = mtab; - var context = mtab.then(contextGet); - var req = await context.then(headerScrub); + context = mtab.then(contextGet); + req = await context.then(headerScrub); console.log("(scrub)Scrubbing I2P Request", req); return req; } else { - var tab = tabGet(requestDetails.tabId); - var context = tab.then(contextGet); - var req = await context.then(headerScrub); + tab = tabGet(requestDetails.tabId); + context = tab.then(contextGet); + req = await context.then(headerScrub); console.log("(scrub)Scrubbing I2P Request", req); return req; } @@ -79,7 +94,7 @@ var contextSetup = async function(requestDetails) { try { var tabFind = async function(tabId) { try { - context = await browser.contextualIdentities.query({ + var context = await browser.contextualIdentities.query({ name: "i2pbrowser" }); if (tabId.cookieStoreId != context[0].cookieStoreId) { @@ -92,14 +107,14 @@ var contextSetup = async function(requestDetails) { ); function Create(window) { function onCreated(tab) { - console.log("(isolate) Closing old, un-isolated tab"); + console.log("(isolate) Closing old, un-isolated tab", window); browser.tabs.remove(tabId.id); browser.tabs.remove(window.tabs[0].id); } function onError(error) { console.log(`Error: ${error}`); } - created = browser.tabs.create({ + var created = browser.tabs.create({ active: true, cookieStoreId: context[0].cookieStoreId, url: requestDetails.url, @@ -107,7 +122,7 @@ var contextSetup = async function(requestDetails) { }); created.then(onCreated, onError); } - getting = browser.windows.getCurrent(); + var getting = browser.windows.getCurrent(); getting.then(Create); return tabId; } @@ -117,7 +132,7 @@ var contextSetup = async function(requestDetails) { }; var routerTabFind = async function(tabId) { try { - context = await browser.contextualIdentities.query({ + var context = await browser.contextualIdentities.query({ name: "routerconsole" }); if (tabId.cookieStoreId != context[0].cookieStoreId) { @@ -137,7 +152,7 @@ var contextSetup = async function(requestDetails) { function onError(error) { console.log(`Error: ${error}`); } - created = browser.tabs.create({ + var created = browser.tabs.create({ active: true, cookieStoreId: context[0].cookieStoreId, url: requestDetails.url, @@ -145,7 +160,7 @@ var contextSetup = async function(requestDetails) { }); created.then(onCreated, onError); } - getting = browser.windows.getCurrent(); + var getting = browser.windows.getCurrent(); getting.then(Create); return tabId; } @@ -175,10 +190,7 @@ var contextSetup = async function(requestDetails) { } } } catch (error) { - console.log( - "(isolate)Not an I2P request, no need to force into alternate cookiestore.", - error - ); + console.log("(isolate)Not an I2P request, blackholing", error); } }; diff --git a/window.html b/window.html index 00b2d88..0a1595e 100644 --- a/window.html +++ b/window.html @@ -40,7 +40,6 @@

-