a little closer to tab-driven private browsing with i2p, re-write user agents globally
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"privacy",
|
||||
"storage",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"contextualIdentities",
|
||||
"cookies",
|
||||
"tabs",
|
||||
|
||||
18
privacy.js
18
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: ["<all_urls>"]},
|
||||
["blocking", "requestHeaders"]
|
||||
);
|
||||
|
||||
function getChrome() {
|
||||
if (chrome.runtime.getBrowserInfo == undefined) {
|
||||
return true
|
||||
|
||||
49
proxy.js
49
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: ["<all_urls>"]}
|
||||
);
|
||||
|
||||
function checkStoredSettings(storedSettings) {
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
|
||||
Reference in New Issue
Block a user