diff --git a/background.js b/background.js index e1aad34..8e97d3c 100644 --- a/background.js +++ b/background.js @@ -99,7 +99,8 @@ function themeWindow(window) { function onError(e) { console.error(e); } - browser.contextualIdentities.get(tabInfo[0].cookieStoreId).then(onGot, onError); + //if (tabInfo[0].cookieStoreId == "firefox-default") + browser.contextualIdentities.get(tabInfo[0].cookieStoreId).then(onGot, onError); } function onError(error) { console.log(`Error: ${error}`); @@ -115,7 +116,7 @@ function setTitle(window) { function logTabs(tabInfo) { console.log(tabInfo) function onGot(context) { - if (context.name == "i2pbrowser") { + if (context.name == "i2pbrowser") { console.log("Active in I2P window") console.log("Active in I2P window") diff --git a/manifest.json b/manifest.json index a0d4aea..a8fb98a 100644 --- a/manifest.json +++ b/manifest.json @@ -13,6 +13,7 @@ "privacy", "storage", "webRequest", + "webRequestBlocking", "contextualIdentities", "cookies", "tabs", diff --git a/privacy.js b/privacy.js index 1e11fc6..4e79503 100644 --- a/privacy.js +++ b/privacy.js @@ -1,4 +1,22 @@ +var ua = "MYOB/6.66 (AN/ON)"; + +function rewriteUserAgentHeader(e) { + for (var header of e.requestHeaders) { + if (header.name.toLowerCase() === "user-agent") { + header.value = ua; + console.log(header.value) + } + } + return {requestHeaders: e.requestHeaders}; +} + +browser.webRequest.onBeforeSendHeaders.addListener( + rewriteUserAgentHeader, + {urls: [""]}, + ["blocking", "requestHeaders"] +); + function getChrome() { if (chrome.runtime.getBrowserInfo == undefined) { return true diff --git a/proxy.js b/proxy.js index 5c7878d..a426f32 100644 --- a/proxy.js +++ b/proxy.js @@ -156,6 +156,55 @@ function setupProxy() { } } +function contextProxy(requestDetails) { + try { + + function onGot(context) { + if (!context) { + console.error("Context not found"); + } else { + var controlHost = getControlHost() + var controlPort = getControlPort(); + var Host = getHost() + var Port = getPort() + var Scheme = getScheme() + if (context.name = "i2pbrowser") { + requestDetails.proxyInfo = {host:Host, port:Port, type:Scheme, proxyDns:true } + console.log("PROXY INFO", requestDetails); + } + } + } + + function onError(e) { + console.error(e); + } + + function tabGot(tab) { + if (!tab) { + console.error("Tab not found"); + } else { + if (tab.cookieStoreId != "firefox-default") + browser.contextualIdentities.get(tab.cookieStoreId).then(onGot, onError); + } + } + + function tabError(e) { + console.error(e); + } + + browser.tabs.get(requestDetails.tabId).then(tabGot, tabError); + + } catch (error) { + console.error(error); + } + console.log(requestDetails); +} + +browser.webRequest.onBeforeRequest.addListener( + contextProxy, + {urls: [""]} +); + function checkStoredSettings(storedSettings) { let defaultSettings = {}; if (!storedSettings.proxy_scheme) {