I2P in Private Browsing Mode has Liftoff!
This commit is contained in:
86
info.js
86
info.js
@@ -1,49 +1,49 @@
|
||||
document.addEventListener("click", (e) => {
|
||||
function getCurrentWindow() {
|
||||
return chrome.windows.getCurrent();
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
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()
|
||||
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();
|
||||
e.preventDefault();
|
||||
|
||||
});
|
||||
@@ -19,13 +19,6 @@
|
||||
"tabs",
|
||||
"<all_urls>"
|
||||
],
|
||||
"protocol_handlers": [
|
||||
{
|
||||
"protocol": "rc",
|
||||
"name": "I2P Router Console",
|
||||
"uriTemplate": "http://localhost:7657/%s"
|
||||
}
|
||||
],
|
||||
"manifest_version": 2,
|
||||
"name": "__MSG_extensionName__",
|
||||
"version": "1.27",
|
||||
@@ -46,6 +39,11 @@
|
||||
"background": {
|
||||
"scripts": ["chromium/browser-polyfill.min.js", "background.js", "proxy.js", "info.js", "privacy.js" ]
|
||||
},
|
||||
"protocol_handlers": [{
|
||||
"protocol": "web+rc",
|
||||
"name": "RouterConsole",
|
||||
"uriTemplate": "http://router.console/?%s"
|
||||
}],
|
||||
"default_locale": "en"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,208 +1,208 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
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() {});
|
||||
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() {});
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
83
proxy.js
83
proxy.js
@@ -40,57 +40,60 @@ function shouldProxyRequest(requestInfo) {
|
||||
return requestInfo.parentFrameId != -1;
|
||||
}
|
||||
|
||||
function handleProxyRequest(requestInfo) {
|
||||
return {
|
||||
failoverTimeout: -1,
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
proxyDns: true
|
||||
}
|
||||
|
||||
|
||||
var onError = function(e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
var proxyInfo = {}
|
||||
|
||||
function handleContextProxyRequest(requestDetails) {
|
||||
console.log("Searching for context");
|
||||
var handleContextProxyRequest = async function(requestDetails) {
|
||||
console.log("Searching for proxy by context");
|
||||
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");
|
||||
return proxyInfo
|
||||
var handleProxyRequest = function(context) {
|
||||
proxy = {
|
||||
failoverTimeout: 0,
|
||||
type: "direct",
|
||||
proxyDns: false
|
||||
}
|
||||
if (context.name == "i2pbrowser") {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort(),
|
||||
}
|
||||
console.log("Using", proxy.type, "proxy ", proxy.host + ":" + proxy.port);
|
||||
return proxy
|
||||
}
|
||||
return proxy
|
||||
}
|
||||
var contextGet = async function(tabInfo){
|
||||
try {
|
||||
console.log("Tab info from Function", tabInfo)
|
||||
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId)
|
||||
return context
|
||||
} catch(error) {
|
||||
console.log("Conext Error", error)
|
||||
}
|
||||
}
|
||||
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);
|
||||
var tabGet = async function(tabId) {
|
||||
try {
|
||||
console.log("Tab ID from Request", tabId)
|
||||
let tabInfo = await browser.tabs.get(tabId)
|
||||
return tabInfo
|
||||
}catch(error){
|
||||
console.log("Tab error", error)
|
||||
}
|
||||
}
|
||||
function tabError(e) {
|
||||
console.error(e);
|
||||
if (requestDetails.tabId > 0) {
|
||||
var tab = tabGet(requestDetails.tabId)
|
||||
var context = tab.then(contextGet)
|
||||
var proxy = await context.then(handleProxyRequest)
|
||||
console.log("Returning I2P Proxy", proxy)
|
||||
return proxy
|
||||
}
|
||||
if (requestDetails.tabId > 0)
|
||||
browser.tabs.get(requestDetails.tabId).then(tabGot, tabError);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.log("Not using I2P Proxy.", error);
|
||||
}
|
||||
console.log("Selected Proxy", proxyInfo);
|
||||
//return proxyInfo
|
||||
}
|
||||
|
||||
var proxy_scheme = "HTTP"
|
||||
|
||||
Reference in New Issue
Block a user