fmt
This commit is contained in:
2
Makefile
2
Makefile
@@ -66,7 +66,7 @@ libpolyfill:
|
||||
wget -O chromium/browser-polyfill.min.js https://unpkg.com/webextension-polyfill/dist/browser-polyfill.min.js
|
||||
|
||||
fmt:
|
||||
find . -path ./node_modules -prune -o -name '*.js' -exec jsfmt -w {} \;
|
||||
find . -path ./node_modules -prune -o -name '*.js' -exec prettier --write {} \;
|
||||
|
||||
deborig:
|
||||
rm -rfv ../i2psetproxy.js-$(VERSION)
|
||||
|
||||
218
background.js
218
background.js
@@ -1,147 +1,153 @@
|
||||
function onGot(contexts) {
|
||||
var ids = []
|
||||
for (let context of contexts) {
|
||||
console.log(`Name: ${context.name}`);
|
||||
ids.push(context.name)
|
||||
var ids = [];
|
||||
for (let context of contexts) {
|
||||
console.log(`Name: ${context.name}`);
|
||||
ids.push(context.name);
|
||||
}
|
||||
if (ids.indexOf("i2pbrowser") == -1) {
|
||||
function onCreated(context) {
|
||||
console.log(`New identity's ID: ${context.cookieStoreId}.`);
|
||||
}
|
||||
if (ids.indexOf("i2pbrowser") == -1) {
|
||||
function onCreated(context) {
|
||||
console.log(`New identity's ID: ${context.cookieStoreId}.`);
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
browser.contextualIdentities.create({
|
||||
name: "i2pbrowser",
|
||||
color: "purple",
|
||||
icon: "fingerprint"
|
||||
}).then(onCreated, onError);
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: "i2pbrowser",
|
||||
color: "purple",
|
||||
icon: "fingerprint"
|
||||
})
|
||||
.then(onCreated, onError);
|
||||
}
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
browser.contextualIdentities.query({}).then(onGot, onError);
|
||||
|
||||
if (!isDroid()) {
|
||||
chrome.windows.onCreated.addListener(themeWindow);
|
||||
chrome.windows.onCreated.addListener(themeWindow);
|
||||
}
|
||||
|
||||
var titlepref = chrome.i18n.getMessage("titlePreface");
|
||||
var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate");
|
||||
|
||||
function themeWindow(window) {
|
||||
// Check if the window is in private browsing
|
||||
function logTabs(tabInfo) {
|
||||
console.log(tabInfo)
|
||||
// Check if the window is in private browsing
|
||||
function logTabs(tabInfo) {
|
||||
console.log(tabInfo);
|
||||
|
||||
function onGot(context) {
|
||||
if (context.name == "i2pbrowser") {
|
||||
console.log("Active in I2P window")
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#2D4470",
|
||||
toolbar: "#2D4470",
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#9DABD5",
|
||||
toolbar: "#9DABD5",
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log("Not active in I2P window")
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: undefined,
|
||||
toolbar: undefined,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: undefined,
|
||||
toolbar: undefined,
|
||||
}
|
||||
});
|
||||
}
|
||||
function onGot(context) {
|
||||
if (context.name == "i2pbrowser") {
|
||||
console.log("Active in I2P window");
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#2D4470",
|
||||
toolbar: "#2D4470"
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#9DABD5",
|
||||
toolbar: "#9DABD5"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
} else {
|
||||
console.log("Not active in I2P window");
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: undefined,
|
||||
toolbar: undefined
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: undefined,
|
||||
toolbar: undefined
|
||||
}
|
||||
});
|
||||
}
|
||||
if (tabInfo[0].cookieStoreId != "firefox-default")
|
||||
browser.contextualIdentities.get(tabInfo[0].cookieStoreId).then(onGot, onError);
|
||||
}
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
});
|
||||
querying.then(logTabs, onError);
|
||||
if (tabInfo[0].cookieStoreId != "firefox-default")
|
||||
browser.contextualIdentities
|
||||
.get(tabInfo[0].cookieStoreId)
|
||||
.then(onGot, onError);
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
});
|
||||
querying.then(logTabs, onError);
|
||||
}
|
||||
|
||||
function setTitle(window) {
|
||||
function logTabs(tabInfo) {
|
||||
console.log(tabInfo)
|
||||
function logTabs(tabInfo) {
|
||||
console.log(tabInfo);
|
||||
|
||||
function onGot(context) {
|
||||
if (context.name == "i2pbrowser") {
|
||||
console.log("Active in I2P window")
|
||||
function onGot(context) {
|
||||
if (context.name == "i2pbrowser") {
|
||||
console.log("Active in I2P window");
|
||||
|
||||
console.log("Active in I2P window")
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
}
|
||||
console.log("Active in I2P window");
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (tabInfo[0].cookieStoreId != "firefox-default")
|
||||
browser.contextualIdentities.get(tabInfo[0].cookieStoreId).then(onGot, onError);
|
||||
}
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
});
|
||||
querying.then(logTabs, onError);
|
||||
if (tabInfo[0].cookieStoreId != "firefox-default")
|
||||
browser.contextualIdentities
|
||||
.get(tabInfo[0].cookieStoreId)
|
||||
.then(onGot, onError);
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
});
|
||||
querying.then(logTabs, onError);
|
||||
}
|
||||
|
||||
chrome.windows.onCreated.addListener(() => {
|
||||
//var gettingStoredSettings = chrome.storage.local.get();
|
||||
//gettingStoredSettings.then(setupProxy, onError);
|
||||
chrome.storage.local.get(function(got) {
|
||||
setupProxy()
|
||||
});
|
||||
//var gettingStoredSettings = chrome.storage.local.get();
|
||||
//gettingStoredSettings.then(setupProxy, onError);
|
||||
chrome.storage.local.get(function(got) {
|
||||
setupProxy();
|
||||
});
|
||||
});
|
||||
|
||||
chrome.tabs.onCreated.addListener(() => {
|
||||
var getting = browser.windows.getCurrent({
|
||||
populate: true
|
||||
});
|
||||
getting.then(setTitle, onError);
|
||||
var getting = browser.windows.getCurrent({
|
||||
populate: true
|
||||
});
|
||||
getting.then(setTitle, onError);
|
||||
});
|
||||
|
||||
247
chromium/browser-polyfill.min.js
vendored
247
chromium/browser-polyfill.min.js
vendored
@@ -7,11 +7,14 @@
|
||||
var c = {
|
||||
exports: {}
|
||||
};
|
||||
b(c), a.browser = c.exports
|
||||
b(c), (a.browser = c.exports);
|
||||
}
|
||||
})(this, function(a) {
|
||||
"use strict";
|
||||
if ("undefined" == typeof browser || Object.getPrototypeOf(browser) !== Object.prototype) {
|
||||
if (
|
||||
"undefined" == typeof browser ||
|
||||
Object.getPrototypeOf(browser) !== Object.prototype
|
||||
) {
|
||||
a.exports = (e => {
|
||||
const f = {
|
||||
alarms: {
|
||||
@@ -676,65 +679,102 @@
|
||||
}
|
||||
};
|
||||
if (0 === Object.keys(f).length) {
|
||||
throw new Error("api-metadata.json has not been included in browser-polyfill");
|
||||
throw new Error(
|
||||
"api-metadata.json has not been included in browser-polyfill"
|
||||
);
|
||||
}
|
||||
class g extends WeakMap {
|
||||
constructor(v, w = void 0) {
|
||||
super(w), this.createItem = v
|
||||
super(w), (this.createItem = v);
|
||||
}
|
||||
get(v) {
|
||||
return this.has(v) || this.set(v, this.createItem(v)), super.get(v)
|
||||
return this.has(v) || this.set(v, this.createItem(v)), super.get(v);
|
||||
}
|
||||
}
|
||||
const h = v => {
|
||||
return v && "object" == typeof v && "function" == typeof v.then
|
||||
return v && "object" == typeof v && "function" == typeof v.then;
|
||||
};
|
||||
const i = (v, w) => {
|
||||
return (...x) => {
|
||||
e.runtime.lastError ? v.reject(e.runtime.lastError) : w.singleCallbackArg || 1 >= x.length && !1 !== w.singleCallbackArg ? v.resolve(x[0]) : v.resolve(x)
|
||||
}
|
||||
e.runtime.lastError
|
||||
? v.reject(e.runtime.lastError)
|
||||
: w.singleCallbackArg ||
|
||||
(1 >= x.length && !1 !== w.singleCallbackArg)
|
||||
? v.resolve(x[0])
|
||||
: v.resolve(x);
|
||||
};
|
||||
};
|
||||
const j = v => 1 == v ? "argument" : "arguments";
|
||||
const j = v => (1 == v ? "argument" : "arguments");
|
||||
const k = (v, w) => {
|
||||
return function(y, ...z) {
|
||||
if (z.length < w.minArgs) {
|
||||
throw new Error(`Expected at least ${w.minArgs} ${j(w.minArgs)} for ${v}(), got ${z.length}`);
|
||||
throw new Error(
|
||||
`Expected at least ${w.minArgs} ${j(w.minArgs)} for ${v}(), got ${
|
||||
z.length
|
||||
}`
|
||||
);
|
||||
}
|
||||
if (z.length > w.maxArgs) {
|
||||
throw new Error(`Expected at most ${w.maxArgs} ${j(w.maxArgs)} for ${v}(), got ${z.length}`);
|
||||
throw new Error(
|
||||
`Expected at most ${w.maxArgs} ${j(w.maxArgs)} for ${v}(), got ${
|
||||
z.length
|
||||
}`
|
||||
);
|
||||
}
|
||||
return new Promise((A, B) => {
|
||||
if (w.fallbackToNoCallback) {
|
||||
try {
|
||||
y[v](...z, i({
|
||||
resolve: A,
|
||||
reject: B
|
||||
}, w))
|
||||
} catch ( C ) {
|
||||
console.warn(`${v} API method doesn't seem to support the callback parameter, ` + "falling back to call it without a callback: ", C), y[v](...z), w.fallbackToNoCallback = !1, w.noCallback = !0, A()
|
||||
y[v](
|
||||
...z,
|
||||
i(
|
||||
{
|
||||
resolve: A,
|
||||
reject: B
|
||||
},
|
||||
w
|
||||
)
|
||||
);
|
||||
} catch (C) {
|
||||
console.warn(
|
||||
`${v} API method doesn't seem to support the callback parameter, ` +
|
||||
"falling back to call it without a callback: ",
|
||||
C
|
||||
),
|
||||
y[v](...z),
|
||||
(w.fallbackToNoCallback = !1),
|
||||
(w.noCallback = !0),
|
||||
A();
|
||||
}
|
||||
} else {
|
||||
w.noCallback ? (y[v](...z), A()) : y[v](...z, i({
|
||||
resolve: A,
|
||||
reject: B
|
||||
}, w))
|
||||
w.noCallback
|
||||
? (y[v](...z), A())
|
||||
: y[v](
|
||||
...z,
|
||||
i(
|
||||
{
|
||||
resolve: A,
|
||||
reject: B
|
||||
},
|
||||
w
|
||||
)
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
const l = (v, w, x) => {
|
||||
return new Proxy(w, {
|
||||
apply(y, z, A) {
|
||||
return x.call(z, v, ...A)
|
||||
return x.call(z, v, ...A);
|
||||
}
|
||||
})
|
||||
});
|
||||
};
|
||||
let m = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
const n = (v, w = {}, x = {}) => {
|
||||
let y = Object.create(null);
|
||||
let z = {
|
||||
has(B, C) {
|
||||
return C in v || C in y
|
||||
return C in v || C in y;
|
||||
},
|
||||
get(B, C) {
|
||||
if (C in y) {
|
||||
@@ -747,104 +787,142 @@
|
||||
E = l(v, v[C], w[C]);
|
||||
} else if (m(x, C)) {
|
||||
let F = k(C, x[C]);
|
||||
E = l(v, v[C], F)
|
||||
E = l(v, v[C], F);
|
||||
} else {
|
||||
E = E.bind(v);
|
||||
}
|
||||
} else if ("object" == typeof E && null !== E && (m(w, C) || m(x, C))) {
|
||||
} else if (
|
||||
"object" == typeof E &&
|
||||
null !== E &&
|
||||
(m(w, C) || m(x, C))
|
||||
) {
|
||||
E = n(E, w[C], x[C]);
|
||||
} else {
|
||||
return Object.defineProperty(y, C, {
|
||||
return (
|
||||
Object.defineProperty(y, C, {
|
||||
configurable: !0,
|
||||
enumerable: !0,
|
||||
get() {
|
||||
return v[C]
|
||||
return v[C];
|
||||
},
|
||||
set(F) {
|
||||
v[C] = F
|
||||
v[C] = F;
|
||||
}
|
||||
}), E;
|
||||
}),
|
||||
E
|
||||
);
|
||||
}
|
||||
return y[C] = E, E
|
||||
return (y[C] = E), E;
|
||||
}
|
||||
},
|
||||
set(B, C, D) {
|
||||
return C in y ? y[C] = D : v[C] = D, !0
|
||||
return C in y ? (y[C] = D) : (v[C] = D), !0;
|
||||
},
|
||||
defineProperty(B, C, D) {
|
||||
return Reflect.defineProperty(y, C, D)
|
||||
return Reflect.defineProperty(y, C, D);
|
||||
},
|
||||
deleteProperty(B, C) {
|
||||
return Reflect.deleteProperty(y, C)
|
||||
return Reflect.deleteProperty(y, C);
|
||||
}
|
||||
};
|
||||
let A = Object.create(v);
|
||||
return new Proxy(A, z)
|
||||
return new Proxy(A, z);
|
||||
};
|
||||
const o = v => ({
|
||||
addListener(w, x, ...y) {
|
||||
w.addListener(v.get(x), ...y)
|
||||
w.addListener(v.get(x), ...y);
|
||||
},
|
||||
hasListener(w, x) {
|
||||
return w.hasListener(v.get(x))
|
||||
return w.hasListener(v.get(x));
|
||||
},
|
||||
removeListener(w, x) {
|
||||
w.removeListener(v.get(x))
|
||||
w.removeListener(v.get(x));
|
||||
}
|
||||
});
|
||||
let p = !1;
|
||||
const q = new g(v => {
|
||||
return "function" == typeof v ? function(x, y, z) {
|
||||
let B;
|
||||
let D;
|
||||
let A = !1;
|
||||
let C = new Promise(G => {
|
||||
B = function(H) {
|
||||
p || (console.warn("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)", new Error().stack), p = !0), A = !0, G(H)
|
||||
return "function" == typeof v
|
||||
? function(x, y, z) {
|
||||
let B;
|
||||
let D;
|
||||
let A = !1;
|
||||
let C = new Promise(G => {
|
||||
B = function(H) {
|
||||
p ||
|
||||
(console.warn(
|
||||
"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)",
|
||||
new Error().stack
|
||||
),
|
||||
(p = !0)),
|
||||
(A = !0),
|
||||
G(H);
|
||||
};
|
||||
});
|
||||
try {
|
||||
D = v(x, y, B);
|
||||
} catch (G) {
|
||||
D = Promise.reject(G);
|
||||
}
|
||||
const E = !0 !== D && h(D);
|
||||
if (!0 !== D && !E && !A) {
|
||||
return !1;
|
||||
}
|
||||
const F = G => {
|
||||
G.then(
|
||||
H => {
|
||||
z(H);
|
||||
},
|
||||
H => {
|
||||
let I;
|
||||
(I =
|
||||
H && (H instanceof Error || "string" == typeof H.message)
|
||||
? H.message
|
||||
: "An unexpected error occurred"),
|
||||
z({
|
||||
__mozWebExtensionPolyfillReject__: !0,
|
||||
message: I
|
||||
});
|
||||
}
|
||||
).catch(H => {
|
||||
console.error("Failed to send onMessage rejected reply", H);
|
||||
});
|
||||
};
|
||||
return E ? F(D) : F(C), !0;
|
||||
}
|
||||
});
|
||||
try {
|
||||
D = v(x, y, B)
|
||||
} catch ( G ) {
|
||||
D = Promise.reject(G)
|
||||
}
|
||||
const E = !0 !== D && h(D);
|
||||
if (!0 !== D && !E && !A) {
|
||||
return !1;
|
||||
}
|
||||
const F = G => {
|
||||
G.then(H => {
|
||||
z(H)
|
||||
}, H => {
|
||||
let I;
|
||||
I = H && (H instanceof Error || "string" == typeof H.message) ? H.message : "An unexpected error occurred", z({
|
||||
__mozWebExtensionPolyfillReject__: !0,
|
||||
message: I
|
||||
})
|
||||
}).catch(H => {
|
||||
console.error("Failed to send onMessage rejected reply", H)
|
||||
})
|
||||
};
|
||||
return E ? F(D) : F(C), !0
|
||||
} : v
|
||||
: v;
|
||||
});
|
||||
const r = ({reject: v, resolve: w} , x) => {
|
||||
e.runtime.lastError ? e.runtime.lastError.message === "The message port closed before a response was received." ? w() : v(e.runtime.lastError) : x && x.__mozWebExtensionPolyfillReject__ ? v(new Error(x.message)) : w(x)
|
||||
const r = ({ reject: v, resolve: w }, x) => {
|
||||
e.runtime.lastError
|
||||
? e.runtime.lastError.message ===
|
||||
"The message port closed before a response was received."
|
||||
? w()
|
||||
: v(e.runtime.lastError)
|
||||
: x && x.__mozWebExtensionPolyfillReject__
|
||||
? v(new Error(x.message))
|
||||
: w(x);
|
||||
};
|
||||
const s = (v, w, x, ...y) => {
|
||||
if (y.length < w.minArgs) {
|
||||
throw new Error(`Expected at least ${w.minArgs} ${j(w.minArgs)} for ${v}(), got ${y.length}`);
|
||||
throw new Error(
|
||||
`Expected at least ${w.minArgs} ${j(w.minArgs)} for ${v}(), got ${
|
||||
y.length
|
||||
}`
|
||||
);
|
||||
}
|
||||
if (y.length > w.maxArgs) {
|
||||
throw new Error(`Expected at most ${w.maxArgs} ${j(w.maxArgs)} for ${v}(), got ${y.length}`);
|
||||
throw new Error(
|
||||
`Expected at most ${w.maxArgs} ${j(w.maxArgs)} for ${v}(), got ${
|
||||
y.length
|
||||
}`
|
||||
);
|
||||
}
|
||||
return new Promise((z, A) => {
|
||||
const B = r.bind(null, {
|
||||
resolve: z,
|
||||
reject: A
|
||||
});
|
||||
y.push(B), x.sendMessage(...y)
|
||||
})
|
||||
y.push(B), x.sendMessage(...y);
|
||||
});
|
||||
};
|
||||
const t = {
|
||||
runtime: {
|
||||
@@ -876,7 +954,8 @@
|
||||
maxArgs: 1
|
||||
}
|
||||
};
|
||||
return f.privacy = {
|
||||
return (
|
||||
(f.privacy = {
|
||||
network: {
|
||||
networkPredictionEnabled: u,
|
||||
webRTCIPHandlingPolicy: u
|
||||
@@ -888,10 +967,12 @@
|
||||
hyperlinkAuditingEnabled: u,
|
||||
referrersEnabled: u
|
||||
}
|
||||
}, n(e, t, f)
|
||||
})(chrome)
|
||||
}),
|
||||
n(e, t, f)
|
||||
);
|
||||
})(chrome);
|
||||
} else {
|
||||
a.exports = browser
|
||||
a.exports = browser;
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=browser-polyfill.min.js.map
|
||||
@@ -900,4 +981,4 @@
|
||||
|
||||
/* 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/. */
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
12
content.js
12
content.js
@@ -1,17 +1,17 @@
|
||||
var infoTitle = document.getElementById('text-section-header');
|
||||
var infoTitle = document.getElementById("text-section-header");
|
||||
infoTitle.textContent = chrome.i18n.getMessage("infoTitle");
|
||||
|
||||
var infoMessage = document.getElementById('text-section-helptext');
|
||||
var infoMessage = document.getElementById("text-section-helptext");
|
||||
infoMessage.textContent = chrome.i18n.getMessage("infoMessage");
|
||||
|
||||
var helpMessage = document.getElementById('window-create-forum-panel');
|
||||
var helpMessage = document.getElementById("window-create-forum-panel");
|
||||
helpMessage.textContent = chrome.i18n.getMessage("forumMessage");
|
||||
/*
|
||||
var helpMessage = document.getElementById('window-create-help-panel');
|
||||
helpMessage.textContent = chrome.i18n.getMessage("helpMessage")
|
||||
*/
|
||||
var newsMessage = document.getElementById('window-create-news-panel');
|
||||
var newsMessage = document.getElementById("window-create-news-panel");
|
||||
newsMessage.textContent = chrome.i18n.getMessage("newsMessage");
|
||||
|
||||
var clearData = document.getElementById("clear-browser-data")
|
||||
clearData.textContent = chrome.i18n.getMessage("clearData");
|
||||
var clearData = document.getElementById("clear-browser-data");
|
||||
clearData.textContent = chrome.i18n.getMessage("clearData");
|
||||
|
||||
116
context.js
116
context.js
@@ -1,70 +1,74 @@
|
||||
//var windowIds = []
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
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
|
||||
});
|
||||
creating.then(onCreated, onError);
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
if (event.target.dataset.action == 'close-all') {
|
||||
browser.tabs.query({
|
||||
cookieStoreId: event.target.dataset.identity
|
||||
}).then((tabs) => {
|
||||
browser.tabs.remove(tabs.map((i) => i.id));
|
||||
});
|
||||
}
|
||||
event.preventDefault();
|
||||
var creating = browser.windows.create({
|
||||
cookieStoreId: event.target.dataset.identity
|
||||
});
|
||||
creating.then(onCreated, onError);
|
||||
}
|
||||
if (event.target.dataset.action == "close-all") {
|
||||
browser.tabs
|
||||
.query({
|
||||
cookieStoreId: event.target.dataset.identity
|
||||
})
|
||||
.then(tabs => {
|
||||
browser.tabs.remove(tabs.map(i => i.id));
|
||||
});
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
var div = document.getElementById('identity-list');
|
||||
var div = document.getElementById("identity-list");
|
||||
|
||||
if (browser.contextualIdentities === undefined) {
|
||||
div.innerText = 'browser.contextualIdentities not available. Check that the privacy.userContext.enabled pref is set to true, and reload the add-on.';
|
||||
div.innerText =
|
||||
"browser.contextualIdentities not available. Check that the privacy.userContext.enabled pref is set to true, and reload the add-on.";
|
||||
} else {
|
||||
browser.contextualIdentities.query({
|
||||
name: "i2pbrowser"
|
||||
})
|
||||
.then((identities) => {
|
||||
if (!identities.length) {
|
||||
div.innerText = 'No identities returned from the API.';
|
||||
return;
|
||||
}
|
||||
browser.contextualIdentities
|
||||
.query({
|
||||
name: "i2pbrowser"
|
||||
})
|
||||
.then(identities => {
|
||||
if (!identities.length) {
|
||||
div.innerText = "No identities returned from the API.";
|
||||
return;
|
||||
}
|
||||
|
||||
for (let identity of identities) {
|
||||
let row = document.createElement('div');
|
||||
let span = document.createElement('span');
|
||||
span.className = 'identity';
|
||||
span.innerText = identity.name;
|
||||
span.style = `color: ${identity.color}`;
|
||||
console.log(identity);
|
||||
row.appendChild(span);
|
||||
createOptions(row, identity);
|
||||
div.appendChild(row);
|
||||
}
|
||||
});
|
||||
}
|
||||
for (let identity of identities) {
|
||||
let row = document.createElement("div");
|
||||
let span = document.createElement("span");
|
||||
span.className = "identity";
|
||||
span.innerText = identity.name;
|
||||
span.style = `color: ${identity.color}`;
|
||||
console.log(identity);
|
||||
row.appendChild(span);
|
||||
createOptions(row, identity);
|
||||
div.appendChild(row);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
25
info.js
25
info.js
@@ -1,4 +1,4 @@
|
||||
document.addEventListener("click", (e) => {
|
||||
document.addEventListener("click", e => {
|
||||
function getCurrentWindow() {
|
||||
return chrome.windows.getCurrent();
|
||||
}
|
||||
@@ -6,7 +6,7 @@ document.addEventListener("click", (e) => {
|
||||
if (e.target.id === "window-create-help-panel") {
|
||||
let createData = {
|
||||
type: "panel",
|
||||
incognito: true,
|
||||
incognito: true
|
||||
};
|
||||
let creating = chrome.windows.create(createData);
|
||||
creating.then(() => {
|
||||
@@ -15,7 +15,7 @@ document.addEventListener("click", (e) => {
|
||||
} else if (e.target.id === "window-create-news-panel") {
|
||||
let createData = {
|
||||
type: "panel",
|
||||
incognito: true,
|
||||
incognito: true
|
||||
};
|
||||
let creating = chrome.windows.create(createData);
|
||||
creating.then(() => {
|
||||
@@ -23,27 +23,26 @@ document.addEventListener("click", (e) => {
|
||||
});
|
||||
} else if (e.target.id === "generate-fresh-tunnel") {
|
||||
function RefreshIdentity() {
|
||||
console.log("Generating new identity")
|
||||
console.log("Generating new identity");
|
||||
const Http = new XMLHttpRequest();
|
||||
const url = 'http://' + controlHost + ":" + controlPort
|
||||
const url = "http://" + controlHost + ":" + controlPort;
|
||||
Http.open("GET", url);
|
||||
Http.send();
|
||||
Http.onreadystatechange = (e) => {
|
||||
console.log(Http.responseText)
|
||||
}
|
||||
Http.onreadystatechange = e => {
|
||||
console.log(Http.responseText);
|
||||
};
|
||||
}
|
||||
RefreshIdentity();
|
||||
} else if (e.target.id === "window-preface-title") {
|
||||
getCurrentWindow().then((currentWindow) => {
|
||||
getCurrentWindow().then(currentWindow => {
|
||||
let updateInfo = {
|
||||
titlePreface: "I2P Help | "
|
||||
}
|
||||
};
|
||||
chrome.windows.update(currentWindow.id, updateInfo);
|
||||
});
|
||||
} else if (e.target.id === "clear-browser-data") {
|
||||
forgetBrowsingData()
|
||||
forgetBrowsingData();
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
function isDroid() {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
gettingInfo.then(got => {
|
||||
if (got.os == "android") {
|
||||
return true
|
||||
return true;
|
||||
} else {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function SetHostText() {
|
||||
var hostid = document.getElementById('hostText');
|
||||
var hostid = document.getElementById("hostText");
|
||||
hostid.textContent = chrome.i18n.getMessage("hostText");
|
||||
}
|
||||
|
||||
function SetPortText() {
|
||||
var portid = document.getElementById('portText');
|
||||
var portid = document.getElementById("portText");
|
||||
portid.textContent = chrome.i18n.getMessage("portText");
|
||||
}
|
||||
|
||||
function SetControlHostText() {
|
||||
var controlhostid = document.getElementById('controlHostText');
|
||||
var controlhostid = document.getElementById("controlHostText");
|
||||
controlhostid.textContent = chrome.i18n.getMessage("controlHostText");
|
||||
}
|
||||
|
||||
function setupProxy() {
|
||||
var controlHost = getControlHost()
|
||||
var controlHost = getControlHost();
|
||||
var controlPort = getControlPort();
|
||||
var Host = getHost()
|
||||
var Port = getPort()
|
||||
var Scheme = getScheme()
|
||||
var Host = getHost();
|
||||
var Port = getPort();
|
||||
var Scheme = getScheme();
|
||||
if (!getChrome()) {
|
||||
function handleProxyRequest(requestInfo) {
|
||||
console.log("proxying request via listener")
|
||||
console.log(" ", Scheme, Host, ":", Port,)
|
||||
console.log("proxying request via listener");
|
||||
console.log(" ", Scheme, Host, ":", Port);
|
||||
return {
|
||||
type: Scheme,
|
||||
host: Host,
|
||||
port: Port,
|
||||
proxyDns: true
|
||||
}
|
||||
};
|
||||
}
|
||||
console.log("Setting up Firefox WebExtension proxy")
|
||||
console.log("Setting up Firefox WebExtension proxy");
|
||||
browser.proxy.onRequest.addListener(handleProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy")
|
||||
console.log("i2p settings created for WebExtension Proxy");
|
||||
} else {
|
||||
var config = {
|
||||
mode: "fixed_servers",
|
||||
@@ -53,24 +53,27 @@ function setupProxy() {
|
||||
singleProxy: {
|
||||
scheme: Scheme,
|
||||
host: Host,
|
||||
port: parseInt(Port),
|
||||
},
|
||||
port: parseInt(Port)
|
||||
}
|
||||
}
|
||||
};
|
||||
chrome.proxy.settings.set({
|
||||
value: config,
|
||||
scope: 'regular'
|
||||
}, function() {});
|
||||
chrome.proxy.settings.set(
|
||||
{
|
||||
value: config,
|
||||
scope: "regular"
|
||||
},
|
||||
function() {}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function SetControlPortText() {
|
||||
var controlportid = document.getElementById('controlPortText');
|
||||
var controlportid = document.getElementById("controlPortText");
|
||||
controlportid.textContent = chrome.i18n.getMessage("controlPortText");
|
||||
}
|
||||
|
||||
function SetControlHelpText() {
|
||||
var portid = document.getElementById('controlHelpText');
|
||||
var portid = document.getElementById("controlHelpText");
|
||||
portid.textContent = chrome.i18n.getMessage("controlHelpText");
|
||||
}
|
||||
|
||||
@@ -78,46 +81,46 @@ function getScheme() {
|
||||
const proxy_scheme = document.querySelector("#proxy_scheme");
|
||||
console.log("Got i2p proxy scheme:", proxy_scheme.value);
|
||||
if (proxy_scheme == "HTTP") {
|
||||
return "http"
|
||||
return "http";
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
return "socks"
|
||||
return "socks";
|
||||
}
|
||||
return proxy_scheme.value;
|
||||
}
|
||||
|
||||
function getHost() {
|
||||
proxy_host = document.getElementById("host").value
|
||||
proxy_host = document.getElementById("host").value;
|
||||
console.log("Got i2p proxy host:", proxy_host);
|
||||
if (proxy_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
return "127.0.0.1";
|
||||
}
|
||||
return proxy_host;
|
||||
}
|
||||
|
||||
function getPort() {
|
||||
proxy_port = document.getElementById("port").value
|
||||
proxy_port = document.getElementById("port").value;
|
||||
console.log("Got i2p proxy port:", proxy_port);
|
||||
if (proxy_port == undefined) {
|
||||
return "4444"
|
||||
return "4444";
|
||||
}
|
||||
return proxy_port;
|
||||
}
|
||||
|
||||
function getControlHost() {
|
||||
control_host = document.getElementById("controlhost").value
|
||||
control_host = document.getElementById("controlhost").value;
|
||||
console.log("Got i2p control host:", control_host);
|
||||
if (control_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
return "127.0.0.1";
|
||||
}
|
||||
return control_host;
|
||||
}
|
||||
|
||||
function getControlPort() {
|
||||
control_port = document.getElementById("controlport").value
|
||||
control_port = document.getElementById("controlport").value;
|
||||
console.log("Got i2p control port:", control_port);
|
||||
if (control_port == undefined) {
|
||||
return "4444"
|
||||
return "4444";
|
||||
}
|
||||
return control_port;
|
||||
}
|
||||
@@ -125,19 +128,19 @@ function getControlPort() {
|
||||
function checkStoredSettings(storedSettings) {
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http"
|
||||
defaultSettings["proxy_scheme"] = "http";
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1"
|
||||
defaultSettings["proxy_host"] = "127.0.0.1";
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444
|
||||
defaultSettings["proxy_port"] = 4444;
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1"
|
||||
defaultSettings["control_host"] = "127.0.0.1";
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444
|
||||
defaultSettings["control_port"] = 4444;
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
}
|
||||
@@ -147,65 +150,64 @@ function onError(e) {
|
||||
}
|
||||
|
||||
function storeSettings() {
|
||||
let proxy_scheme = getScheme()
|
||||
let proxy_host = getHost()
|
||||
let proxy_port = getPort()
|
||||
let control_host = getControlHost()
|
||||
let control_port = getControlPort()
|
||||
let proxy_scheme = getScheme();
|
||||
let proxy_host = getHost();
|
||||
let proxy_port = getPort();
|
||||
let control_host = getControlHost();
|
||||
let control_port = getControlPort();
|
||||
chrome.storage.local.set({
|
||||
proxy_scheme,
|
||||
proxy_host,
|
||||
proxy_port,
|
||||
control_host,
|
||||
control_port,
|
||||
control_port
|
||||
});
|
||||
console.log("storing proxy scheme:", proxy_scheme)
|
||||
console.log("storing proxy host:", proxy_host)
|
||||
console.log("storing proxy port:", proxy_port)
|
||||
console.log("storing control host:", control_host)
|
||||
console.log("storing control port:", control_port)
|
||||
setupProxy()
|
||||
console.log("storing proxy scheme:", proxy_scheme);
|
||||
console.log("storing proxy host:", proxy_host);
|
||||
console.log("storing proxy port:", proxy_port);
|
||||
console.log("storing control host:", control_host);
|
||||
console.log("storing control port:", control_port);
|
||||
setupProxy();
|
||||
}
|
||||
|
||||
function updateUI(restoredSettings) {
|
||||
const selectList = document.querySelector("#proxy_scheme");
|
||||
selectList.value = restoredSettings.proxy_scheme;
|
||||
console.log("showing proxy scheme:", selectList.value);
|
||||
|
||||
const selectList = document.querySelector("#proxy_scheme")
|
||||
selectList.value = restoredSettings.proxy_scheme
|
||||
console.log("showing proxy scheme:", selectList.value)
|
||||
const hostitem = document.getElementById("host");
|
||||
hostitem.value = restoredSettings.proxy_host;
|
||||
console.log("showing proxy host:", hostitem.value);
|
||||
|
||||
const hostitem = document.getElementById("host")
|
||||
hostitem.value = restoredSettings.proxy_host
|
||||
console.log("showing proxy host:", hostitem.value)
|
||||
const portitem = document.getElementById("port");
|
||||
portitem.value = restoredSettings.proxy_port;
|
||||
console.log("showing proxy port:", portitem.value);
|
||||
|
||||
const portitem = document.getElementById("port")
|
||||
portitem.value = restoredSettings.proxy_port
|
||||
console.log("showing proxy port:", portitem.value)
|
||||
const controlhostitem = document.getElementById("controlhost");
|
||||
controlhostitem.value = restoredSettings.control_host;
|
||||
console.log("showing control host:", controlhostitem.value);
|
||||
|
||||
const controlhostitem = document.getElementById("controlhost")
|
||||
controlhostitem.value = restoredSettings.control_host
|
||||
console.log("showing control host:", controlhostitem.value)
|
||||
const controlportitem = document.getElementById("controlport");
|
||||
controlportitem.value = restoredSettings.control_port;
|
||||
console.log("showing control port:", controlportitem.value);
|
||||
|
||||
const controlportitem = document.getElementById("controlport")
|
||||
controlportitem.value = restoredSettings.control_port
|
||||
console.log("showing control port:", controlportitem.value)
|
||||
|
||||
SetHostText()
|
||||
SetPortText()
|
||||
SetControlHostText()
|
||||
SetControlPortText()
|
||||
SetControlHelpText()
|
||||
setupProxy()
|
||||
SetHostText();
|
||||
SetPortText();
|
||||
SetControlHostText();
|
||||
SetControlPortText();
|
||||
SetControlHelpText();
|
||||
setupProxy();
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
chrome.storage.local.get(function(got) {
|
||||
checkStoredSettings(got)
|
||||
updateUI(got)
|
||||
checkStoredSettings(got);
|
||||
updateUI(got);
|
||||
});
|
||||
|
||||
const saveButton = document.querySelector("#save-button");
|
||||
saveButton.addEventListener("click", storeSettings);
|
||||
|
||||
//EXPERIMENTAL: Open in I2P Tab
|
||||
//EXPERIMENTAL: Open in I2P Tab
|
||||
|
||||
375
privacy.js
375
privacy.js
@@ -1,67 +1,67 @@
|
||||
function getChrome() {
|
||||
if (chrome.runtime.getBrowserInfo == undefined) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
if (chrome.runtime.getBrowserInfo == undefined) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function onSet(result) {
|
||||
if (result) {
|
||||
console.log("->: Value was updated");
|
||||
} else {
|
||||
console.log("-X: Value was not updated");
|
||||
}
|
||||
if (result) {
|
||||
console.log("->: Value was updated");
|
||||
} else {
|
||||
console.log("-X: Value was not updated");
|
||||
}
|
||||
}
|
||||
|
||||
// This disables queries to centralized databases of bad URLs to screen for
|
||||
// risky sites in your browser
|
||||
function disableHyperlinkAuditing() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Disabling hyperlink auditing/val=", {
|
||||
value: false
|
||||
})
|
||||
setting.then(onSet);
|
||||
}
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Disabling hyperlink auditing/val=", {
|
||||
value: false
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
}
|
||||
|
||||
// This enables first-party isolation
|
||||
function enableFirstPartyIsolation() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.firstPartyIsolate.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabling first party isolation/val=", {
|
||||
value: true
|
||||
})
|
||||
setting.then(onSet);
|
||||
}
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.firstPartyIsolate.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabling first party isolation/val=", {
|
||||
value: true
|
||||
});
|
||||
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
|
||||
function disableEvilCookies() {
|
||||
if (!getChrome()) {
|
||||
var getting = browser.privacy.websites.cookieConfig.get({});
|
||||
getting.then((got) => {
|
||||
var setting = browser.privacy.websites.cookieConfig.set({
|
||||
value: {
|
||||
behavior: "reject_third_party",
|
||||
nonPersistentCookies: got.value.nonPersistentCookies
|
||||
}
|
||||
});
|
||||
console.log("Setting cookie behavior/val=", {
|
||||
value: {
|
||||
behavior: "reject_third_party",
|
||||
nonPersistentCookies: got.value.nonPersistentCookies
|
||||
}
|
||||
})
|
||||
setting.then(onSet);
|
||||
});
|
||||
}
|
||||
if (!getChrome()) {
|
||||
var getting = browser.privacy.websites.cookieConfig.get({});
|
||||
getting.then(got => {
|
||||
var setting = browser.privacy.websites.cookieConfig.set({
|
||||
value: {
|
||||
behavior: "reject_third_party",
|
||||
nonPersistentCookies: got.value.nonPersistentCookies
|
||||
}
|
||||
});
|
||||
console.log("Setting cookie behavior/val=", {
|
||||
value: {
|
||||
behavior: "reject_third_party",
|
||||
nonPersistentCookies: got.value.nonPersistentCookies
|
||||
}
|
||||
});
|
||||
setting.then(onSet);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that they're gone
|
||||
@@ -77,208 +77,221 @@ function disableEvilCookies() {
|
||||
|
||||
// this disables the use of referrer headers
|
||||
function disableReferrers() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.referrersEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Disabling referrer headers/val=", {
|
||||
value: false
|
||||
})
|
||||
setting.then(onSet);
|
||||
}
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.referrersEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Disabling referrer headers/val=", {
|
||||
value: false
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
}
|
||||
|
||||
// enable fingerprinting resistent features(letterboxing and stuff)
|
||||
function enableResistFingerprinting() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.referrersEnabled.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabling resist fingerprinting/val=", {
|
||||
value: true
|
||||
})
|
||||
setting.then(onSet);
|
||||
}
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.referrersEnabled.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabling resist fingerprinting/val=", {
|
||||
value: true
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
}
|
||||
|
||||
// This is essentially a blocklist of clearnet web-sites known to do bad tracking
|
||||
function enableTrackingProtection() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.trackingProtectionMode.set({
|
||||
value: "always"
|
||||
});
|
||||
console.log("Enabling tracking protection/val=", {
|
||||
value: "always"
|
||||
})
|
||||
setting.then(onSet);
|
||||
}
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.trackingProtectionMode.set({
|
||||
value: "always"
|
||||
});
|
||||
console.log("Enabling tracking protection/val=", {
|
||||
value: "always"
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
}
|
||||
|
||||
// This disables protected content, which is a form of digital restrictions
|
||||
// management dependent on identifying information
|
||||
function disableDigitalRestrictionsManagement() {
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "win") {
|
||||
var setting = browser.privacy.websites.protectedContentEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Setting Protected Content(Digital Restrictions Management) false/val=", {
|
||||
value: false
|
||||
})
|
||||
setting.then(onSet);
|
||||
}
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
if (got.os == "win") {
|
||||
var setting = browser.privacy.websites.protectedContentEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
console.log(
|
||||
"Setting Protected Content(Digital Restrictions Management) false/val=",
|
||||
{
|
||||
value: false
|
||||
}
|
||||
);
|
||||
setting.then(onSet);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setAllPrivacy() {
|
||||
disableHyperlinkAuditing()
|
||||
enableFirstPartyIsolation()
|
||||
disableEvilCookies()
|
||||
disableReferrers()
|
||||
enableTrackingProtection()
|
||||
enableResistFingerprinting()
|
||||
disableDigitalRestrictionsManagement()
|
||||
disableHyperlinkAuditing();
|
||||
enableFirstPartyIsolation();
|
||||
disableEvilCookies();
|
||||
disableReferrers();
|
||||
enableTrackingProtection();
|
||||
enableResistFingerprinting();
|
||||
disableDigitalRestrictionsManagement();
|
||||
}
|
||||
|
||||
setAllPrivacy()
|
||||
setAllPrivacy();
|
||||
|
||||
function ResetPeerConnection() {
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Re-disabled WebRTC")
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
});
|
||||
console.log("Re-disabled WebRTC");
|
||||
}
|
||||
|
||||
function EnablePeerConnection() {
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: true
|
||||
});
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabled WebRTC")
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
});
|
||||
console.log("Enabled WebRTC");
|
||||
}
|
||||
|
||||
ResetPeerConnection()
|
||||
ResetPeerConnection();
|
||||
|
||||
function ResetDisableSavePasswords() {
|
||||
browser.privacy.services.passwordSavingEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Re-disabled saved passwords")
|
||||
browser.privacy.services.passwordSavingEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Re-disabled saved passwords");
|
||||
}
|
||||
|
||||
function EnableSavePasswords() {
|
||||
browser.privacy.services.passwordSavingEnabled.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabled saved passwords")
|
||||
browser.privacy.services.passwordSavingEnabled.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabled saved passwords");
|
||||
}
|
||||
|
||||
//ResetDisableSavePasswords()
|
||||
|
||||
|
||||
var defaultSettings = {
|
||||
since: "forever",
|
||||
dataTypes: ["history", "downloads", "cache", "cookies", "passwords", "pluginData", "formData", "serviceWorkers"]
|
||||
since: "forever",
|
||||
dataTypes: [
|
||||
"history",
|
||||
"downloads",
|
||||
"cache",
|
||||
"cookies",
|
||||
"passwords",
|
||||
"pluginData",
|
||||
"formData",
|
||||
"serviceWorkers"
|
||||
]
|
||||
};
|
||||
|
||||
var appSettings = {
|
||||
since: "forever",
|
||||
dataTypes: [""]
|
||||
since: "forever",
|
||||
dataTypes: [""]
|
||||
};
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
function checkStoredSettings(storedSettings) {
|
||||
chrome.storage.local.set(appSettings);
|
||||
chrome.storage.local.set(appSettings);
|
||||
}
|
||||
|
||||
if (!getChrome()) {
|
||||
const gettingStoredSettings = browser.storage.local.get();
|
||||
gettingStoredSettings.then(checkStoredSettings, onError);
|
||||
const gettingStoredSettings = browser.storage.local.get();
|
||||
gettingStoredSettings.then(checkStoredSettings, onError);
|
||||
}
|
||||
|
||||
function forgetBrowsingData(storedSettings) {
|
||||
|
||||
function getSince(selectedSince) {
|
||||
if (selectedSince === "forever") {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const times = {
|
||||
hour: () => {
|
||||
return 1000 * 60 * 60
|
||||
},
|
||||
day: () => {
|
||||
return 1000 * 60 * 60 * 24
|
||||
},
|
||||
week: () => {
|
||||
return 1000 * 60 * 60 * 24 * 7
|
||||
}
|
||||
}
|
||||
|
||||
const sinceMilliseconds = times[selectedSince].call();
|
||||
return Date.now() - sinceMilliseconds;
|
||||
function getSince(selectedSince) {
|
||||
if (selectedSince === "forever") {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function getTypes(selectedTypes) {
|
||||
let dataTypes = {};
|
||||
for (let item of selectedTypes) {
|
||||
dataTypes[item] = true;
|
||||
}
|
||||
return dataTypes;
|
||||
const times = {
|
||||
hour: () => {
|
||||
return 1000 * 60 * 60;
|
||||
},
|
||||
day: () => {
|
||||
return 1000 * 60 * 60 * 24;
|
||||
},
|
||||
week: () => {
|
||||
return 1000 * 60 * 60 * 24 * 7;
|
||||
}
|
||||
};
|
||||
|
||||
const sinceMilliseconds = times[selectedSince].call();
|
||||
return Date.now() - sinceMilliseconds;
|
||||
}
|
||||
|
||||
function getTypes(selectedTypes) {
|
||||
let dataTypes = {};
|
||||
for (let item of selectedTypes) {
|
||||
dataTypes[item] = true;
|
||||
}
|
||||
return dataTypes;
|
||||
}
|
||||
|
||||
const since = getSince(defaultSettings.since);
|
||||
const dataTypes = getTypes(defaultSettings.dataTypes);
|
||||
const since = getSince(defaultSettings.since);
|
||||
const dataTypes = getTypes(defaultSettings.dataTypes);
|
||||
|
||||
function notify() {
|
||||
let dataTypesString = Object.keys(dataTypes).join(", ");
|
||||
let sinceString = new Date(since).toLocaleString();
|
||||
browser.notifications.create({
|
||||
"type": "basic",
|
||||
"title": "Removed browsing data",
|
||||
"message": `Removed ${dataTypesString}\nsince ${sinceString}`
|
||||
});
|
||||
}
|
||||
function notify() {
|
||||
let dataTypesString = Object.keys(dataTypes).join(", ");
|
||||
let sinceString = new Date(since).toLocaleString();
|
||||
browser.notifications.create({
|
||||
type: "basic",
|
||||
title: "Removed browsing data",
|
||||
message: `Removed ${dataTypesString}\nsince ${sinceString}`
|
||||
});
|
||||
}
|
||||
|
||||
browser.browsingData.remove({
|
||||
browser.browsingData
|
||||
.remove(
|
||||
{
|
||||
since
|
||||
}, dataTypes).then(notify);
|
||||
|
||||
setAllPrivacy()
|
||||
ResetPeerConnection()
|
||||
},
|
||||
dataTypes
|
||||
)
|
||||
.then(notify);
|
||||
|
||||
setAllPrivacy();
|
||||
ResetPeerConnection();
|
||||
}
|
||||
|
||||
|
||||
function onGot(contexts) {
|
||||
for (let context of contexts) {
|
||||
console.log(context);
|
||||
}
|
||||
for (let context of contexts) {
|
||||
console.log(context);
|
||||
}
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
browser.contextualIdentities.query({}).then(onGot, onError);
|
||||
browser.contextualIdentities.query({}).then(onGot, onError);
|
||||
|
||||
155
proxy.js
155
proxy.js
@@ -1,9 +1,8 @@
|
||||
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Preliminarily disabled WebRTC.")
|
||||
console.log("Preliminarily disabled WebRTC.");
|
||||
}
|
||||
|
||||
chrome.privacy.network.networkPredictionEnabled.set({
|
||||
@@ -25,86 +24,91 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
failoverTimeout: 0,
|
||||
type: "direct",
|
||||
proxyDns: false
|
||||
}
|
||||
};
|
||||
if (context.name == "i2pbrowser") {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
}
|
||||
console.log("(proxy)Using", proxy.type, "proxy ", proxy.host + ":" + proxy.port);
|
||||
return proxy
|
||||
port: getPort()
|
||||
};
|
||||
console.log(
|
||||
"(proxy)Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
return proxy;
|
||||
}
|
||||
return proxy
|
||||
}
|
||||
return proxy;
|
||||
};
|
||||
var contextGet = async function(tabInfo) {
|
||||
try {
|
||||
console.log("(proxy)Tab info from Function", tabInfo)
|
||||
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId)
|
||||
return context
|
||||
} catch ( error ) {
|
||||
console.log("(proxy)Conext Error", error)
|
||||
console.log("(proxy)Tab info from Function", tabInfo);
|
||||
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
|
||||
return context;
|
||||
} catch (error) {
|
||||
console.log("(proxy)Conext Error", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
var tabGet = async function(tabId) {
|
||||
try {
|
||||
console.log("(proxy)Tab ID from Request", tabId)
|
||||
let tabInfo = await browser.tabs.get(tabId)
|
||||
return tabInfo
|
||||
} catch ( error ) {
|
||||
console.log("(proxy)Tab error", error)
|
||||
console.log("(proxy)Tab ID from Request", tabId);
|
||||
let tabInfo = await browser.tabs.get(tabId);
|
||||
return tabInfo;
|
||||
} catch (error) {
|
||||
console.log("(proxy)Tab error", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (requestDetails.tabId > 0) {
|
||||
var tab = tabGet(requestDetails.tabId)
|
||||
var context = tab.then(contextGet)
|
||||
var proxy = await context.then(handleProxyRequest)
|
||||
console.log("(proxy)Returning I2P Proxy", proxy)
|
||||
return proxy
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var context = tab.then(contextGet);
|
||||
var proxy = await context.then(handleProxyRequest);
|
||||
console.log("(proxy)Returning I2P Proxy", proxy);
|
||||
return proxy;
|
||||
}
|
||||
} catch ( error ) {
|
||||
} catch (error) {
|
||||
console.log("(proxy)Not using I2P Proxy.", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var proxy_scheme = "HTTP"
|
||||
var proxy_scheme = "HTTP";
|
||||
|
||||
function getScheme() {
|
||||
if (proxy_scheme == undefined) {
|
||||
proxy_scheme = "http"
|
||||
proxy_scheme = "http";
|
||||
}
|
||||
if (proxy_scheme == "HTTP") {
|
||||
proxy_scheme = "http"
|
||||
proxy_scheme = "http";
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
proxy_scheme = "socks"
|
||||
proxy_scheme = "socks";
|
||||
}
|
||||
if (proxy_scheme != "http" && proxy_scheme != "socks") {
|
||||
proxy_scheme = "http"
|
||||
proxy_scheme = "http";
|
||||
}
|
||||
//console.log("Got i2p proxy scheme:", proxy_scheme);
|
||||
return proxy_scheme;
|
||||
}
|
||||
|
||||
var proxy_host = "127.0.0.1"
|
||||
var proxy_port = "4444"
|
||||
var control_host = "127.0.0.1"
|
||||
var control_port = "4444"
|
||||
var proxy_host = "127.0.0.1";
|
||||
var proxy_port = "4444";
|
||||
var control_host = "127.0.0.1";
|
||||
var control_port = "4444";
|
||||
|
||||
function getHost() {
|
||||
if (proxy_host == undefined) {
|
||||
proxy_host = "127.0.0.1"
|
||||
proxy_host = "127.0.0.1";
|
||||
}
|
||||
return proxy_host;
|
||||
}
|
||||
|
||||
function getPort() {
|
||||
if (proxy_port == undefined) {
|
||||
var scheme = getScheme()
|
||||
var scheme = getScheme();
|
||||
if (scheme == "socks") {
|
||||
proxy_port = "4446"
|
||||
proxy_port = "4446";
|
||||
} else {
|
||||
proxy_port = "4444"
|
||||
proxy_port = "4444";
|
||||
}
|
||||
}
|
||||
return proxy_port;
|
||||
@@ -112,32 +116,32 @@ function getPort() {
|
||||
|
||||
function getControlHost() {
|
||||
if (control_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
return "127.0.0.1";
|
||||
}
|
||||
return control_host;
|
||||
}
|
||||
|
||||
function getControlPort() {
|
||||
if (control_port == undefined) {
|
||||
return "4444"
|
||||
return "4444";
|
||||
}
|
||||
return control_port;
|
||||
}
|
||||
|
||||
function setupProxy() {
|
||||
var controlHost = getControlHost()
|
||||
var controlHost = getControlHost();
|
||||
var controlPort = getControlPort();
|
||||
var Host = getHost()
|
||||
var Port = getPort()
|
||||
var Scheme = getScheme()
|
||||
var Host = getHost();
|
||||
var Port = getPort();
|
||||
var Scheme = getScheme();
|
||||
if (!getChrome()) {
|
||||
/**/
|
||||
console.log("Setting up Firefox WebExtension proxy")
|
||||
console.log("Setting up Firefox WebExtension proxy");
|
||||
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy")
|
||||
/**/
|
||||
console.log("i2p settings created for WebExtension Proxy");
|
||||
/**/
|
||||
} else {
|
||||
var config = {
|
||||
mode: "fixed_servers",
|
||||
@@ -145,54 +149,57 @@ function setupProxy() {
|
||||
singleProxy: {
|
||||
scheme: Scheme,
|
||||
host: Host,
|
||||
port: parseInt(Port),
|
||||
},
|
||||
port: parseInt(Port)
|
||||
}
|
||||
}
|
||||
};
|
||||
chrome.proxy.settings.set({
|
||||
value: config,
|
||||
scope: 'regular'
|
||||
}, function() {});
|
||||
chrome.proxy.settings.set(
|
||||
{
|
||||
value: config,
|
||||
scope: "regular"
|
||||
},
|
||||
function() {}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function checkStoredSettings(storedSettings) {
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http"
|
||||
defaultSettings["proxy_scheme"] = "http";
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1"
|
||||
defaultSettings["proxy_host"] = "127.0.0.1";
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444
|
||||
defaultSettings["proxy_port"] = 4444;
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1"
|
||||
defaultSettings["control_host"] = "127.0.0.1";
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444
|
||||
defaultSettings["control_port"] = 4444;
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
}
|
||||
|
||||
function update(restoredSettings) {
|
||||
proxy_scheme = restoredSettings.proxy_scheme
|
||||
console.log("restoring proxy scheme:", proxy_scheme)
|
||||
proxy_host = restoredSettings.proxy_host
|
||||
console.log("restoring proxy host:", proxy_host)
|
||||
proxy_port = restoredSettings.proxy_port
|
||||
console.log("restoring proxy port:", proxy_port)
|
||||
control_host = restoredSettings.control_host
|
||||
console.log("restoring control host:", control_host)
|
||||
control_port = restoredSettings.control_port
|
||||
console.log("restoring control port:", control_port)
|
||||
proxy_scheme = restoredSettings.proxy_scheme;
|
||||
console.log("restoring proxy scheme:", proxy_scheme);
|
||||
proxy_host = restoredSettings.proxy_host;
|
||||
console.log("restoring proxy host:", proxy_host);
|
||||
proxy_port = restoredSettings.proxy_port;
|
||||
console.log("restoring proxy port:", proxy_port);
|
||||
control_host = restoredSettings.control_host;
|
||||
console.log("restoring control host:", control_host);
|
||||
control_port = restoredSettings.control_port;
|
||||
console.log("restoring control port:", control_port);
|
||||
}
|
||||
|
||||
chrome.storage.local.get(function(got) {
|
||||
checkStoredSettings(got)
|
||||
update(got)
|
||||
setupProxy()
|
||||
checkStoredSettings(got);
|
||||
update(got);
|
||||
setupProxy();
|
||||
});
|
||||
|
||||
// Theme all currently open windows
|
||||
|
||||
99
scrub.js
99
scrub.js
@@ -1,57 +1,56 @@
|
||||
|
||||
var contextScrub = async function(requestDetails) {
|
||||
console.log("(scrub)Scrubbing info from contextualized request");
|
||||
try {
|
||||
var headerScrub = function(context) {
|
||||
if (!context) {
|
||||
console.error("Context not found");
|
||||
} else {
|
||||
if (context.name = "i2pbrowser") {
|
||||
var ua = "MYOB/6.66 (AN/ON)";
|
||||
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
|
||||
};
|
||||
}
|
||||
console.log("(scrub)Scrubbing info from contextualized request");
|
||||
try {
|
||||
var headerScrub = function(context) {
|
||||
if (!context) {
|
||||
console.error("Context not found");
|
||||
} else {
|
||||
if ((context.name = "i2pbrowser")) {
|
||||
var ua = "MYOB/6.66 (AN/ON)";
|
||||
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
|
||||
};
|
||||
}
|
||||
var contextGet = async function(tabInfo){
|
||||
try {
|
||||
console.log("(scrub)Tab info from Function", tabInfo)
|
||||
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId)
|
||||
return context
|
||||
} catch(error) {
|
||||
console.log("(scrub)Conext Error", error)
|
||||
}
|
||||
}
|
||||
var tabGet = async function(tabId) {
|
||||
try {
|
||||
console.log("(scrub)Tab ID from Request", tabId)
|
||||
let tabInfo = await browser.tabs.get(tabId)
|
||||
return tabInfo
|
||||
}catch(error){
|
||||
console.log("(scrub)Tab error", error)
|
||||
}
|
||||
}
|
||||
if (requestDetails.tabId > 0) {
|
||||
var tab = tabGet(requestDetails.tabId)
|
||||
var context = tab.then(contextGet)
|
||||
var req = await context.then(headerScrub)
|
||||
console.log("(scrub)Returning I2P Proxy", req)
|
||||
return req
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(scrub)Not using I2P Proxy.", error);
|
||||
}
|
||||
};
|
||||
var contextGet = async function(tabInfo) {
|
||||
try {
|
||||
console.log("(scrub)Tab info from Function", tabInfo);
|
||||
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
|
||||
return context;
|
||||
} catch (error) {
|
||||
console.log("(scrub)Conext Error", error);
|
||||
}
|
||||
};
|
||||
var tabGet = async function(tabId) {
|
||||
try {
|
||||
console.log("(scrub)Tab ID from Request", tabId);
|
||||
let tabInfo = await browser.tabs.get(tabId);
|
||||
return tabInfo;
|
||||
} catch (error) {
|
||||
console.log("(scrub)Tab error", error);
|
||||
}
|
||||
};
|
||||
if (requestDetails.tabId > 0) {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var context = tab.then(contextGet);
|
||||
var req = await context.then(headerScrub);
|
||||
console.log("(scrub)Returning I2P Proxy", req);
|
||||
return req;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(scrub)Not using I2P Proxy.", error);
|
||||
}
|
||||
};
|
||||
|
||||
browser.webRequest.onBeforeSendHeaders.addListener(
|
||||
contextScrub,
|
||||
{urls: ["<all_urls>"]},
|
||||
["blocking", "requestHeaders"]
|
||||
contextScrub,
|
||||
{ urls: ["<all_urls>"] },
|
||||
["blocking", "requestHeaders"]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user