it almost knows how to change I2P identity based on contextual identity
This commit is contained in:
2
Makefile
2
Makefile
@@ -63,4 +63,4 @@ libpolyfill:
|
||||
wget -O chromium/browser-polyfill.min.js https://unpkg.com/webextension-polyfill/dist/browser-polyfill.min.js
|
||||
|
||||
fmt:
|
||||
find . -name '*.js' -exec jsfmt -w {} \;
|
||||
find . -name '*.js' -exec js-beautify -r -f {} \;
|
||||
|
257
background.js
257
background.js
@@ -1,163 +1,174 @@
|
||||
|
||||
function onGot(contexts) {
|
||||
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}.`);
|
||||
var ids = []
|
||||
for (let context of contexts) {
|
||||
console.log(`Name: ${context.name}`);
|
||||
ids.push(context.name)
|
||||
}
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
|
||||
|
||||
function getChrome() {
|
||||
if (browser.runtime.getBrowserInfo == undefined) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
if (browser.runtime.getBrowserInfo == undefined) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function isDroid() {
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
console.log("android detected")
|
||||
return true
|
||||
} else {
|
||||
console.log("desktop detected")
|
||||
return false
|
||||
}
|
||||
});
|
||||
}
|
||||
return false
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
console.log("android detected")
|
||||
return true
|
||||
} else {
|
||||
console.log("desktop detected")
|
||||
return false
|
||||
}
|
||||
});
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
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)
|
||||
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,
|
||||
}
|
||||
});
|
||||
}
|
||||
// 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 onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (tabInfo[0].cookieStoreId != "firefox-default")
|
||||
browser.contextualIdentities.get(tabInfo[0].cookieStoreId).then(onGot, onError);
|
||||
}
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
//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);
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
});
|
||||
querying.then(logTabs, onError);
|
||||
}
|
||||
|
||||
function setTitle(window) {
|
||||
function logTabs(tabInfo) {
|
||||
console.log(tabInfo)
|
||||
function onGot(context) {
|
||||
if (context.name == "i2pbrowser") {
|
||||
console.log("Active in I2P window")
|
||||
function logTabs(tabInfo) {
|
||||
console.log(tabInfo)
|
||||
|
||||
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 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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
});
|
||||
querying.then(logTabs, onError);
|
||||
}
|
||||
|
||||
function setTitleError(window) {
|
||||
alert("plugin error setting title on", window.id)
|
||||
alert("plugin error setting title on", window.id)
|
||||
}
|
||||
|
||||
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()
|
||||
});
|
||||
});
|
||||
|
||||
chrome.tabs.onCreated.addListener(() => {
|
||||
var getting = browser.windows.getCurrent({
|
||||
populate: true
|
||||
});
|
||||
getting.then(setTitle, setTitleError);
|
||||
});
|
||||
var getting = browser.windows.getCurrent({
|
||||
populate: true
|
||||
});
|
||||
getting.then(setTitle, setTitleError);
|
||||
});
|
1773
chromium/browser-polyfill.min.js
vendored
1773
chromium/browser-polyfill.min.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -14,5 +14,4 @@ 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");
|
||||
|
||||
clearData.textContent = chrome.i18n.getMessage("clearData");
|
108
context.js
108
context.js
@@ -1,68 +1,70 @@
|
||||
|
||||
//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);
|
||||
}
|
||||
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));
|
||||
});
|
||||
}
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
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();
|
||||
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');
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
90
info.js
90
info.js
@@ -1,49 +1,49 @@
|
||||
document.addEventListener("click", (e) => {
|
||||
function getCurrentWindow() {
|
||||
return chrome.windows.getCurrent();
|
||||
}
|
||||
|
||||
if (e.target.id === "window-create-help-panel") {
|
||||
let createData = {
|
||||
type: "panel",
|
||||
incognito: true,
|
||||
};
|
||||
let creating = chrome.windows.create(createData);
|
||||
creating.then(() => {
|
||||
console.log("The help panel has been created");
|
||||
});
|
||||
} else if (e.target.id === "window-create-news-panel") {
|
||||
let createData = {
|
||||
type: "panel",
|
||||
incognito: true,
|
||||
};
|
||||
let creating = chrome.windows.create(createData);
|
||||
creating.then(() => {
|
||||
console.log("The news panel has been created");
|
||||
});
|
||||
} else if (e.target.id === "generate-fresh-tunnel") {
|
||||
function RefreshIdentity() {
|
||||
console.log("Generating new identity")
|
||||
const Http = new XMLHttpRequest();
|
||||
const url = 'http://' + controlHost + ":" + controlPort
|
||||
Http.open("GET", url);
|
||||
Http.send();
|
||||
Http.onreadystatechange = (e) => {
|
||||
console.log(Http.responseText)
|
||||
}
|
||||
function getCurrentWindow() {
|
||||
return chrome.windows.getCurrent();
|
||||
}
|
||||
RefreshIdentity();
|
||||
} else if (e.target.id === "window-preface-title") {
|
||||
getCurrentWindow().then((currentWindow) => {
|
||||
let updateInfo = {
|
||||
titlePreface: "I2P Help | "
|
||||
}
|
||||
chrome.windows.update(currentWindow.id, updateInfo);
|
||||
});
|
||||
} else if (e.target.id === "clear-browser-data") {
|
||||
forgetBrowsingData()
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
if (e.target.id === "window-create-help-panel") {
|
||||
let createData = {
|
||||
type: "panel",
|
||||
incognito: true,
|
||||
};
|
||||
let creating = chrome.windows.create(createData);
|
||||
creating.then(() => {
|
||||
console.log("The help panel has been created");
|
||||
});
|
||||
} else if (e.target.id === "window-create-news-panel") {
|
||||
let createData = {
|
||||
type: "panel",
|
||||
incognito: true,
|
||||
};
|
||||
let creating = chrome.windows.create(createData);
|
||||
creating.then(() => {
|
||||
console.log("The news panel has been created");
|
||||
});
|
||||
} else if (e.target.id === "generate-fresh-tunnel") {
|
||||
function RefreshIdentity() {
|
||||
console.log("Generating new identity")
|
||||
const Http = new XMLHttpRequest();
|
||||
const url = 'http://' + controlHost + ":" + controlPort
|
||||
Http.open("GET", url);
|
||||
Http.send();
|
||||
Http.onreadystatechange = (e) => {
|
||||
console.log(Http.responseText)
|
||||
}
|
||||
}
|
||||
RefreshIdentity();
|
||||
} else if (e.target.id === "window-preface-title") {
|
||||
getCurrentWindow().then((currentWindow) => {
|
||||
let updateInfo = {
|
||||
titlePreface: "I2P Help | "
|
||||
}
|
||||
chrome.windows.update(currentWindow.id, updateInfo);
|
||||
});
|
||||
} else if (e.target.id === "clear-browser-data") {
|
||||
forgetBrowsingData()
|
||||
}
|
||||
|
||||
});
|
||||
e.preventDefault();
|
||||
|
||||
});
|
@@ -1,214 +1,211 @@
|
||||
|
||||
function isDroid() {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
});
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function SetHostText() {
|
||||
var hostid = document.getElementById('hostText');
|
||||
hostid.textContent = chrome.i18n.getMessage("hostText");
|
||||
var hostid = document.getElementById('hostText');
|
||||
hostid.textContent = chrome.i18n.getMessage("hostText");
|
||||
}
|
||||
|
||||
function SetPortText() {
|
||||
var portid = document.getElementById('portText');
|
||||
portid.textContent = chrome.i18n.getMessage("portText");
|
||||
var portid = document.getElementById('portText');
|
||||
portid.textContent = chrome.i18n.getMessage("portText");
|
||||
}
|
||||
|
||||
function SetControlHostText() {
|
||||
var controlhostid = document.getElementById('controlHostText');
|
||||
controlhostid.textContent = chrome.i18n.getMessage("controlHostText");
|
||||
var controlhostid = document.getElementById('controlHostText');
|
||||
controlhostid.textContent = chrome.i18n.getMessage("controlHostText");
|
||||
}
|
||||
|
||||
function setupProxy() {
|
||||
var controlHost = getControlHost()
|
||||
var controlPort = getControlPort();
|
||||
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,)
|
||||
return {
|
||||
type: Scheme,
|
||||
host: Host,
|
||||
port: Port,
|
||||
proxyDns: true
|
||||
}
|
||||
var controlHost = getControlHost()
|
||||
var controlPort = getControlPort();
|
||||
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, )
|
||||
return {
|
||||
type: Scheme,
|
||||
host: Host,
|
||||
port: Port,
|
||||
proxyDns: true
|
||||
}
|
||||
}
|
||||
console.log("Setting up Firefox WebExtension proxy")
|
||||
browser.proxy.onRequest.addListener(handleProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy")
|
||||
} else {
|
||||
var config = {
|
||||
mode: "fixed_servers",
|
||||
rules: {
|
||||
singleProxy: {
|
||||
scheme: Scheme,
|
||||
host: Host,
|
||||
port: parseInt(Port),
|
||||
},
|
||||
}
|
||||
};
|
||||
chrome.proxy.settings.set({
|
||||
value: config,
|
||||
scope: 'regular'
|
||||
}, function() {});
|
||||
}
|
||||
console.log("Setting up Firefox WebExtension proxy")
|
||||
browser.proxy.onRequest.addListener(handleProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy")
|
||||
} else {
|
||||
var config = {
|
||||
mode: "fixed_servers",
|
||||
rules: {
|
||||
singleProxy: {
|
||||
scheme: Scheme,
|
||||
host: Host,
|
||||
port: parseInt(Port),
|
||||
},
|
||||
}
|
||||
};
|
||||
chrome.proxy.settings.set(
|
||||
{
|
||||
value: config,
|
||||
scope: 'regular'
|
||||
}, function() {});
|
||||
}
|
||||
}
|
||||
|
||||
function SetControlPortText() {
|
||||
var controlportid = document.getElementById('controlPortText');
|
||||
controlportid.textContent = chrome.i18n.getMessage("controlPortText");
|
||||
var controlportid = document.getElementById('controlPortText');
|
||||
controlportid.textContent = chrome.i18n.getMessage("controlPortText");
|
||||
}
|
||||
|
||||
function SetControlHelpText() {
|
||||
var portid = document.getElementById('controlHelpText');
|
||||
portid.textContent = chrome.i18n.getMessage("controlHelpText");
|
||||
var portid = document.getElementById('controlHelpText');
|
||||
portid.textContent = chrome.i18n.getMessage("controlHelpText");
|
||||
}
|
||||
|
||||
function getScheme() {
|
||||
const proxy_scheme = document.querySelector("#proxy_scheme");
|
||||
console.log("Got i2p proxy scheme:", proxy_scheme.value);
|
||||
if (proxy_scheme == "HTTP") {
|
||||
return "http"
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
return "socks"
|
||||
}
|
||||
return proxy_scheme.value;
|
||||
const proxy_scheme = document.querySelector("#proxy_scheme");
|
||||
console.log("Got i2p proxy scheme:", proxy_scheme.value);
|
||||
if (proxy_scheme == "HTTP") {
|
||||
return "http"
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
return "socks"
|
||||
}
|
||||
return proxy_scheme.value;
|
||||
}
|
||||
|
||||
function getHost() {
|
||||
proxy_host = document.getElementById("host").value
|
||||
console.log("Got i2p proxy host:", proxy_host);
|
||||
if (proxy_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
return proxy_host;
|
||||
proxy_host = document.getElementById("host").value
|
||||
console.log("Got i2p proxy host:", proxy_host);
|
||||
if (proxy_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
return proxy_host;
|
||||
}
|
||||
|
||||
function getPort() {
|
||||
proxy_port = document.getElementById("port").value
|
||||
console.log("Got i2p proxy port:", proxy_port);
|
||||
if (proxy_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
return proxy_port;
|
||||
proxy_port = document.getElementById("port").value
|
||||
console.log("Got i2p proxy port:", proxy_port);
|
||||
if (proxy_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
return proxy_port;
|
||||
}
|
||||
|
||||
function getControlHost() {
|
||||
control_host = document.getElementById("controlhost").value
|
||||
console.log("Got i2p control host:", control_host);
|
||||
if (control_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
return control_host;
|
||||
control_host = document.getElementById("controlhost").value
|
||||
console.log("Got i2p control host:", control_host);
|
||||
if (control_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
return control_host;
|
||||
}
|
||||
|
||||
function getControlPort() {
|
||||
control_port = document.getElementById("controlport").value
|
||||
console.log("Got i2p control port:", control_port);
|
||||
if (control_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
return control_port;
|
||||
control_port = document.getElementById("controlport").value
|
||||
console.log("Got i2p control port:", control_port);
|
||||
if (control_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
return control_port;
|
||||
}
|
||||
|
||||
function checkStoredSettings(storedSettings) {
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http"
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http"
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
function storeSettings() {
|
||||
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,
|
||||
});
|
||||
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()
|
||||
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,
|
||||
});
|
||||
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);
|
||||
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
|
263
privacy.js
263
privacy.js
@@ -1,46 +1,27 @@
|
||||
|
||||
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
|
||||
}
|
||||
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()){
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
|
||||
value: false
|
||||
value: false
|
||||
});
|
||||
console.log("Disabling hyperlink auditing/val=", {
|
||||
value: false
|
||||
value: false
|
||||
})
|
||||
setting.then(onSet);
|
||||
}
|
||||
@@ -50,10 +31,10 @@ function disableHyperlinkAuditing() {
|
||||
function enableFirstPartyIsolation() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.firstPartyIsolate.set({
|
||||
value: true
|
||||
value: true
|
||||
});
|
||||
console.log("Enabling first party isolation/val=", {
|
||||
value: true
|
||||
value: true
|
||||
})
|
||||
setting.then(onSet);
|
||||
}
|
||||
@@ -66,12 +47,18 @@ 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}})
|
||||
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);
|
||||
});
|
||||
}
|
||||
@@ -90,27 +77,27 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,10 +105,10 @@ function enableResistFingerprinting() {
|
||||
function enableTrackingProtection() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.trackingProtectionMode.set({
|
||||
value: "always"
|
||||
value: "always"
|
||||
});
|
||||
console.log("Enabling tracking protection/val=", {
|
||||
value: "always"
|
||||
value: "always"
|
||||
})
|
||||
setting.then(onSet);
|
||||
}
|
||||
@@ -130,19 +117,19 @@ function enableTrackingProtection() {
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,33 +145,49 @@ function setAllPrivacy() {
|
||||
|
||||
setAllPrivacy()
|
||||
|
||||
function ResetPeerConnection(){
|
||||
function ResetPeerConnection() {
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({value: false});
|
||||
browser.privacy.network.networkPredictionEnabled.set({value: false});
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({value: "disable_non_proxied_udp"});
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
});
|
||||
console.log("Re-disabled WebRTC")
|
||||
}
|
||||
|
||||
function EnablePeerConnection(){
|
||||
function EnablePeerConnection() {
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({value: true});
|
||||
browser.privacy.network.networkPredictionEnabled.set({value: false});
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: true
|
||||
});
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({value: "disable_non_proxied_udp"});
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
});
|
||||
console.log("Enabled WebRTC")
|
||||
}
|
||||
|
||||
ResetPeerConnection()
|
||||
|
||||
function ResetDisableSavePasswords(){
|
||||
browser.privacy.services.passwordSavingEnabled.set({value: false});
|
||||
function ResetDisableSavePasswords() {
|
||||
browser.privacy.services.passwordSavingEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Re-disabled saved passwords")
|
||||
}
|
||||
|
||||
function EnableSavePasswords(){
|
||||
browser.privacy.services.passwordSavingEnabled.set({value: true});
|
||||
function EnableSavePasswords() {
|
||||
browser.privacy.services.passwordSavingEnabled.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabled saved passwords")
|
||||
}
|
||||
|
||||
@@ -192,82 +195,90 @@ function EnableSavePasswords(){
|
||||
|
||||
|
||||
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()){
|
||||
if (!getChrome()) {
|
||||
const gettingStoredSettings = browser.storage.local.get();
|
||||
gettingStoredSettings.then(checkStoredSettings, onError);
|
||||
}
|
||||
|
||||
function forgetBrowsingData(storedSettings) {
|
||||
|
||||
function getSince(selectedSince) {
|
||||
if (selectedSince === "forever") {
|
||||
return 0;
|
||||
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;
|
||||
}
|
||||
|
||||
const times = {
|
||||
hour: () => { return 1000 * 60 * 60 },
|
||||
day: () => { return 1000 * 60 * 60 * 24 },
|
||||
week: () => { return 1000 * 60 * 60 * 24 * 7}
|
||||
function getTypes(selectedTypes) {
|
||||
let dataTypes = {};
|
||||
for (let item of selectedTypes) {
|
||||
dataTypes[item] = true;
|
||||
}
|
||||
return dataTypes;
|
||||
}
|
||||
|
||||
const sinceMilliseconds = times[selectedSince].call();
|
||||
return Date.now() - sinceMilliseconds;
|
||||
}
|
||||
const since = getSince(defaultSettings.since);
|
||||
const dataTypes = getTypes(defaultSettings.dataTypes);
|
||||
|
||||
function getTypes(selectedTypes) {
|
||||
let dataTypes = {};
|
||||
for (let item of selectedTypes) {
|
||||
dataTypes[item] = true;
|
||||
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}`
|
||||
});
|
||||
}
|
||||
return dataTypes;
|
||||
}
|
||||
|
||||
const since = getSince(defaultSettings.since);
|
||||
const dataTypes = getTypes(defaultSettings.dataTypes);
|
||||
browser.browsingData.remove({
|
||||
since
|
||||
}, dataTypes).then(notify);
|
||||
|
||||
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({since}, dataTypes).then(notify);
|
||||
|
||||
setAllPrivacy()
|
||||
ResetPeerConnection()
|
||||
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);
|
418
proxy.js
418
proxy.js
@@ -1,252 +1,278 @@
|
||||
|
||||
function getChrome() {
|
||||
if (browser.runtime.getBrowserInfo == undefined) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
if (browser.runtime.getBrowserInfo == undefined) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function isDroid() {
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
console.log("android detected")
|
||||
return true
|
||||
} else {
|
||||
console.log("desktop detected")
|
||||
return false
|
||||
}
|
||||
});
|
||||
}
|
||||
return false
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
console.log("android detected")
|
||||
return true
|
||||
} else {
|
||||
console.log("desktop detected")
|
||||
return false
|
||||
}
|
||||
});
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
|
||||
chrome.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
value: false
|
||||
});
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
value: "disable_non_proxied_udp"
|
||||
});
|
||||
|
||||
console.log("Preliminarily disabled WebRTC.")
|
||||
|
||||
function shouldProxyRequest(requestInfo) {
|
||||
return requestInfo.parentFrameId != -1;
|
||||
return requestInfo.parentFrameId != -1;
|
||||
}
|
||||
|
||||
function handleProxyRequest(requestInfo) {
|
||||
console.log(`Proxying: ${requestInfo.url}`);
|
||||
console.log(" ", getScheme(), getHost(), ":", getPort(),)
|
||||
return {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
return {
|
||||
failoverTimeout: -1,
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
proxyDns: true
|
||||
}
|
||||
}
|
||||
|
||||
function handleContextProxyRequest(requestDetails) {
|
||||
console.log("Searching for context");
|
||||
var proxyInfo = handleProxyRequest(requestDetails)
|
||||
try {
|
||||
function onGot(context) {
|
||||
if (!context) {
|
||||
console.error("Context not found");
|
||||
proxyInfo = {}
|
||||
return
|
||||
} else {
|
||||
console.log("Found context", context.name);
|
||||
if (context.name = "i2pbrowser") {
|
||||
proxyInfo = handleProxyRequest(requestDetails)
|
||||
console.log("Using I2P proxy", proxyInfo);
|
||||
return proxyInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
function tabGot(tab) {
|
||||
if (!tab) {
|
||||
console.error("Tab not found");
|
||||
} else {
|
||||
console.log("Found cookieStoreId", tab.cookieStoreId);
|
||||
if (tab.cookieStoreId != "firefox-default")
|
||||
browser.contextualIdentities.get(tab.cookieStoreId).then(onGot, onError);
|
||||
}
|
||||
}
|
||||
function tabError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (requestDetails.tabId > 0)
|
||||
browser.tabs.get(requestDetails.tabId).then(tabGot, tabError);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
console.log(proxyInfo);
|
||||
return proxyInfo
|
||||
}
|
||||
|
||||
var proxy_scheme = "HTTP"
|
||||
|
||||
function getScheme() {
|
||||
if (proxy_scheme == undefined) {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
if (proxy_scheme == "HTTP") {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
proxy_scheme = "socks"
|
||||
}
|
||||
if (proxy_scheme != "http" && proxy_scheme != "socks") {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
console.log("Got i2p proxy scheme:", proxy_scheme);
|
||||
return proxy_scheme;
|
||||
if (proxy_scheme == undefined) {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
if (proxy_scheme == "HTTP") {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
if (proxy_scheme == "SOCKS") {
|
||||
proxy_scheme = "socks"
|
||||
}
|
||||
if (proxy_scheme != "http" && proxy_scheme != "socks") {
|
||||
proxy_scheme = "http"
|
||||
}
|
||||
//console.log("Got i2p proxy scheme:", proxy_scheme);
|
||||
return proxy_scheme;
|
||||
}
|
||||
|
||||
var proxy_host = "127.0.0.1"
|
||||
|
||||
function getHost() {
|
||||
if (proxy_host == undefined) {
|
||||
proxy_host = "127.0.0.1"
|
||||
}
|
||||
console.log("Got i2p proxy host:", proxy_host);
|
||||
return proxy_host;
|
||||
}
|
||||
|
||||
var proxy_port = "4444"
|
||||
|
||||
function getPort() {
|
||||
if (proxy_port == undefined) {
|
||||
var scheme = getScheme()
|
||||
if (scheme == "socks") {
|
||||
proxy_port = "4446"
|
||||
} else {
|
||||
proxy_port = "4444"
|
||||
}
|
||||
}
|
||||
console.log("Got i2p proxy port:", proxy_port);
|
||||
return proxy_port;
|
||||
}
|
||||
|
||||
var control_host = "127.0.0.1"
|
||||
|
||||
function getControlHost() {
|
||||
if (control_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
console.log("Got i2p control host:", control_host);
|
||||
return control_host;
|
||||
}
|
||||
|
||||
var control_port = "4444"
|
||||
|
||||
function getHost() {
|
||||
if (proxy_host == undefined) {
|
||||
proxy_host = "127.0.0.1"
|
||||
}
|
||||
return proxy_host;
|
||||
}
|
||||
|
||||
function getPort() {
|
||||
if (proxy_port == undefined) {
|
||||
var scheme = getScheme()
|
||||
if (scheme == "socks") {
|
||||
proxy_port = "4446"
|
||||
} else {
|
||||
proxy_port = "4444"
|
||||
}
|
||||
}
|
||||
return proxy_port;
|
||||
}
|
||||
|
||||
function getControlHost() {
|
||||
if (control_host == undefined) {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
return control_host;
|
||||
}
|
||||
|
||||
function getControlPort() {
|
||||
if (control_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
console.log("Got i2p control port:", control_port);
|
||||
return control_port;
|
||||
if (control_port == undefined) {
|
||||
return "4444"
|
||||
}
|
||||
return control_port;
|
||||
}
|
||||
|
||||
function setupProxy() {
|
||||
var controlHost = getControlHost()
|
||||
var controlPort = getControlPort();
|
||||
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,)
|
||||
return {
|
||||
type: Scheme,
|
||||
host: Host,
|
||||
port: Port,
|
||||
proxyDns: true
|
||||
}
|
||||
var controlHost = getControlHost()
|
||||
var controlPort = getControlPort();
|
||||
var Host = getHost()
|
||||
var Port = getPort()
|
||||
var Scheme = getScheme()
|
||||
if (!getChrome()) {
|
||||
/**/
|
||||
console.log("Setting up Firefox WebExtension proxy")
|
||||
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy")
|
||||
/**/
|
||||
} else {
|
||||
var config = {
|
||||
mode: "fixed_servers",
|
||||
rules: {
|
||||
singleProxy: {
|
||||
scheme: Scheme,
|
||||
host: Host,
|
||||
port: parseInt(Port),
|
||||
},
|
||||
}
|
||||
};
|
||||
chrome.proxy.settings.set({
|
||||
value: config,
|
||||
scope: 'regular'
|
||||
}, function() {});
|
||||
}
|
||||
console.log("Setting up Firefox WebExtension proxy")
|
||||
browser.proxy.onRequest.addListener(handleProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy")
|
||||
} else {
|
||||
var config = {
|
||||
mode: "fixed_servers",
|
||||
rules: {
|
||||
singleProxy: {
|
||||
scheme: Scheme,
|
||||
host: Host,
|
||||
port: parseInt(Port),
|
||||
},
|
||||
}
|
||||
};
|
||||
chrome.proxy.settings.set(
|
||||
{
|
||||
value: config,
|
||||
scope: 'regular'
|
||||
}, function() {});
|
||||
}
|
||||
}
|
||||
|
||||
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 contextScrub(requestDetails) {
|
||||
try {
|
||||
function onGot(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(header.value)
|
||||
}
|
||||
}
|
||||
return {
|
||||
requestHeaders: requestDetails.requestHeaders
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
console.log(requestDetails);
|
||||
}
|
||||
|
||||
browser.webRequest.onBeforeRequest.addListener(
|
||||
contextProxy,
|
||||
{urls: ["<all_urls>"]}
|
||||
);
|
||||
/*browser.webRequest.onBeforeSendHeaders.addListener(
|
||||
contextScrub,
|
||||
{urls: ["<all_urls>"]},
|
||||
["blocking", "requestHeaders"]
|
||||
);*/
|
||||
|
||||
function checkStoredSettings(storedSettings) {
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http"
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http"
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1"
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
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
|
||||
if (!getChrome()) {
|
||||
if (!isDroid()) {
|
||||
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
|
||||
}
|
||||
if (!isDroid()) {
|
||||
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user