diff --git a/Makefile b/Makefile index 18f5b81..93d40e7 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +default: zip install: uninstall mkdir -p /usr/share/webext/i2psetproxy.js@eyedeekay.github.io \ @@ -24,7 +25,7 @@ uninstall: clobber: rm -f ../i2psetproxy.js.zip ../i2p_proxy*.xpi -VERSION=1.21 +VERSION=1.23 xpi: mv ~/Downloads/i2p_proxy-$(VERSION)-an+fx.xpi ../i2psetproxy.js@eyedeekay.github.io.xpi diff --git a/README.md b/README.md index f2f0ed0..6393923 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Browser or the I2P Firefox Profile for now. Features -------- - * [done] **Indicate** the i2p browser is in use verbally and symbolically. + * [done] **Indicate** the i2p browser is in use visually * [done] **Set** the http proxy to use the local i2p proxy * [done] **Disable** risky webRTC features * [done] **Change** the color of the browser window to indicate that i2p is in use diff --git a/_locales/en/messages.json b/_locales/en/messages.json index cdc99bb..27d58b7 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -32,7 +32,15 @@ "description": "Help Message" }, "newsMessage": { - "message": "Visit the I2P News to learn the latest about i2p.", + "message": "Visit the I2P Blog to learn the latest about i2p.", + "description": "Help Message" + }, + "forumMessage": { + "message": "Visit the I2P Forum to learn more or ask for assistance", + "description": "Help Message" + }, + "clearData": { + "message": "Clear all browsing data", "description": "Help Message" }, "hostText": { diff --git a/android-ext.pac b/android-ext.pac index d1618bc..53fd271 100644 --- a/android-ext.pac +++ b/android-ext.pac @@ -1,3 +1,180 @@ -function FindProxyForURL(url, host) { - return "PROXY 127.0.0.1:7950"; +/******************************************************* +** Proxy Auto Configure Script with I2P Host Detection. +** +** Author: Cervantes +** License: Public Domain +** Date: 11 May 2004 +** +** Revised: 07 Sep 2004 +** Changes: +** Proxy recursion disabled by default (strict) +** Password Authentication for session commands +** Support for http://path?i2paddresshelper=BASE64 +** Support for http://i2p/BASE64/path syntax +** Revised: 17 May 2004 +** Changes: +** Ability for the user to control the proxy +** status on a per browser-session basis. +********************************************************/ + + +/* C O N F I G U R A T I O N +*/ + +/* Replace normal with "PROXY yourproxy:port" if you run +** behind a Proxy Server by default. +*/ +var normal = "DIRECT"; + +/* Specify the I2P proxy connection details here. +*/ + +var i2pProxy = "PROXY 127.0.0.1:7950"; + +/* Set the default status of proxy detection here: +** +** +** [1] "auto" => Proxy will be used automatically if +** '-> an ".i2p" url is detected. +** '-> You will only be anonymous for ".i2p" domains. +** +** [2] "on" => Proxy is enabled all the time. (safest) +** '-> NB. Normal web available only via +** '-> i2p outproxies. +** '-> You can be fairly confident of anonymity. +** +** [3] "off" => Completely Bypass the proxy and therefore i2p. +** '-> no i2p sites will be accessible... +** '-> ...your browsing habits can potentially +** '-> be traced back to you! +** +*/ + +var proxyStatus = "on"; + +/* By setting statusKeyword to "all" you can set these options at runtime +** for the duration of the browser session by entering special commands +** into your browser address bar. +** +** Due to limitations in the way proxy scripting works, a malicious site +** could change your status mode by linking to command keywords... +** eg. All proxy status urls are available. +** '-> i2p.on, i2p.off, i2p.auto (respective to proxyStatus settings) +** '-> WARNING: Setting "all" is a big risk to your anonymity! +** '-> In this mode it is highly recommended you set an AuthPassword too! +** +** [2] "limited" => Only i2p.on is available.. +** '-> This setting lasts for the duration of the browser setting. +** '-> You have to close your browser in order to revert to +** '-> your default proxyStatus configuration. +** +** [3] "off" => No command urls available. +** '-> The status mode can only be altered by editing the above +** '-> proxyStatus setting. (safest) +** +*/ + +var statusKeyword = "on"; + +/* +** By default if proxyStatus is set to "auto" the config script +** will fall back to your normal connection settings if the +** i2p proxy is offline. This is handy for browsing your locally +** hosted eepsites when your router is not running (for instance). +** However this can mean that requests to external eepsites could +** be forwarded to the outweb and potentially compromise some of +** your rights to anonymity. +** Setting "true" here enables strict mode where all requests to ".i2p" +** sites will be rejected if the i2p proxy is offline. (safest) +*/ + +var strict = true; + +/* +** By setting an authentication password, all activated session keywords +** will require the addition of a password to prevent malicious sites from +** hijacking your proxy settings. ie. if the i2p router is offline. +*/ + +if (strict == false) { + i2pProxy = i2pProxy + "; " + normal; +} + +/*Check for User Authentication Password. +*/ +if (keywordAuthPassword != "") { + keywordAuthPassword = "." + keywordAuthPassword; +} + +/* This function gets called every time a url is submitted +*/ + +function FindProxyForURL(url, host) { + /* checks for a special command url that + ** '-> changes the status of the proxy script. + */ + + if (statusKeyword != "off") { + if (host == "i2p.off" + keywordAuthPassword && statusKeyword == "all") { + /*Proxy is bypassed - outweb available only + */ + proxyStatus = "off"; + } else if (host == "i2p.auto" + keywordAuthPassword && statusKeyword == "all") { + /* Proxy is used only for .i2p hosts otherwise + ** '-> browse as normal. + */ + proxyStatus = "auto"; + } else if (host == "i2p.on" + keywordAuthPassword && (statusKeyword == "limited" || + statusKeyword == "all" )) { + /* Only I2P traffic is accepted. + */ + proxyStatus = "on"; + } + } + + if (proxyStatus == "off") { + /* Proxy is completely bypassed. + */ + return normal; + } else if (proxyStatus == "on") { + /* All requests are forward to the proxy. + */ + return i2pProxy; + } + + host = host.toLowerCase(); + /* check tld for "i2p" or oOo's new "i2paddresshelper" syntax - if found then redirect + ** '-> request to the i2p proxy + */ + + if (url.match(/^http:\/\/i2p\/[a-zA-Z0-9\-\~]{516}|i2paddresshelper=/i) || + shExpMatch(host, "*.i2p")) { // seems more reliable than: + return i2pProxy; // dnsDomainIs(host, ".i2p") || + } else { // i2pRegex.test(host) + return normal; + } } diff --git a/android.pac b/android.pac index e19940a..4016e54 100644 --- a/android.pac +++ b/android.pac @@ -1,3 +1,180 @@ -function FindProxyForURL(url, host) { - return "PROXY 127.0.0.1:4444"; +/******************************************************* +** Proxy Auto Configure Script with I2P Host Detection. +** +** Author: Cervantes +** License: Public Domain +** Date: 11 May 2004 +** +** Revised: 07 Sep 2004 +** Changes: +** Proxy recursion disabled by default (strict) +** Password Authentication for session commands +** Support for http://path?i2paddresshelper=BASE64 +** Support for http://i2p/BASE64/path syntax +** Revised: 17 May 2004 +** Changes: +** Ability for the user to control the proxy +** status on a per browser-session basis. +********************************************************/ + + +/* C O N F I G U R A T I O N +*/ + +/* Replace normal with "PROXY yourproxy:port" if you run +** behind a Proxy Server by default. +*/ +var normal = "DIRECT"; + +/* Specify the I2P proxy connection details here. +*/ + +var i2pProxy = "PROXY 127.0.0.1:4444"; + +/* Set the default status of proxy detection here: +** +** +** [1] "auto" => Proxy will be used automatically if +** '-> an ".i2p" url is detected. +** '-> You will only be anonymous for ".i2p" domains. +** +** [2] "on" => Proxy is enabled all the time. (safest) +** '-> NB. Normal web available only via +** '-> i2p outproxies. +** '-> You can be fairly confident of anonymity. +** +** [3] "off" => Completely Bypass the proxy and therefore i2p. +** '-> no i2p sites will be accessible... +** '-> ...your browsing habits can potentially +** '-> be traced back to you! +** +*/ + +var proxyStatus = "on"; + +/* By setting statusKeyword to "all" you can set these options at runtime +** for the duration of the browser session by entering special commands +** into your browser address bar. +** +** Due to limitations in the way proxy scripting works, a malicious site +** could change your status mode by linking to command keywords... +** eg. All proxy status urls are available. +** '-> i2p.on, i2p.off, i2p.auto (respective to proxyStatus settings) +** '-> WARNING: Setting "all" is a big risk to your anonymity! +** '-> In this mode it is highly recommended you set an AuthPassword too! +** +** [2] "limited" => Only i2p.on is available.. +** '-> This setting lasts for the duration of the browser setting. +** '-> You have to close your browser in order to revert to +** '-> your default proxyStatus configuration. +** +** [3] "off" => No command urls available. +** '-> The status mode can only be altered by editing the above +** '-> proxyStatus setting. (safest) +** +*/ + +var statusKeyword = "off"; + +/* +** By default if proxyStatus is set to "auto" the config script +** will fall back to your normal connection settings if the +** i2p proxy is offline. This is handy for browsing your locally +** hosted eepsites when your router is not running (for instance). +** However this can mean that requests to external eepsites could +** be forwarded to the outweb and potentially compromise some of +** your rights to anonymity. +** Setting "true" here enables strict mode where all requests to ".i2p" +** sites will be rejected if the i2p proxy is offline. (safest) +*/ + +var strict = true; + +/* +** By setting an authentication password, all activated session keywords +** will require the addition of a password to prevent malicious sites from +** hijacking your proxy settings. ie. if the i2p router is offline. +*/ + +if (strict == false) { + i2pProxy = i2pProxy + "; " + normal; +} + +/*Check for User Authentication Password. +*/ +if (keywordAuthPassword != "") { + keywordAuthPassword = "." + keywordAuthPassword; +} + +/* This function gets called every time a url is submitted +*/ + +function FindProxyForURL(url, host) { + /* checks for a special command url that + ** '-> changes the status of the proxy script. + */ + + if (statusKeyword != "off") { + if (host == "i2p.off" + keywordAuthPassword && statusKeyword == "all") { + /*Proxy is bypassed - outweb available only + */ + proxyStatus = "off"; + } else if (host == "i2p.auto" + keywordAuthPassword && statusKeyword == "all") { + /* Proxy is used only for .i2p hosts otherwise + ** '-> browse as normal. + */ + proxyStatus = "auto"; + } else if (host == "i2p.on" + keywordAuthPassword && (statusKeyword == "limited" || + statusKeyword == "all" )) { + /* Only I2P traffic is accepted. + */ + proxyStatus = "on"; + } + } + + if (proxyStatus == "off") { + /* Proxy is completely bypassed. + */ + return normal; + } else if (proxyStatus == "on") { + /* All requests are forward to the proxy. + */ + return i2pProxy; + } + + host = host.toLowerCase(); + /* check tld for "i2p" or oOo's new "i2paddresshelper" syntax - if found then redirect + ** '-> request to the i2p proxy + */ + + if (url.match(/^http:\/\/i2p\/[a-zA-Z0-9\-\~]{516}|i2paddresshelper=/i) || + shExpMatch(host, "*.i2p")) { // seems more reliable than: + return i2pProxy; // dnsDomainIs(host, ".i2p") || + } else { // i2pRegex.test(host) + return normal; + } } diff --git a/background.js b/background.js index fad3548..f5a0504 100644 --- a/background.js +++ b/background.js @@ -7,14 +7,9 @@ function themeWindow(window) { // Check if the window is in private browsing if (window.incognito) { chrome.theme.update(window.id, { - images: { - theme_frame: "icons/toopie.png", - }, colors: { frame: "#A0A0DE", - textcolor: "white", toolbar: "#A0A0DE", - toolbar_text: "white" } }); chrome.windows.update(window.id, { @@ -23,14 +18,9 @@ function themeWindow(window) { } else { chrome.theme.update(window.id, { - images: { - theme_frame: "icons/toopie.png", - }, colors: { frame: "#BFA0DE", - textcolor: "white", toolbar: "#BFA0DE", - toolbar_text: "white" } }); chrome.windows.update(window.id, { @@ -62,6 +52,6 @@ chrome.windows.onCreated.addListener(() => { }); chrome.tabs.onCreated.addListener(() => { - const getting = chrome.windows.getCurrent({populate: true}); + const getting = browser.windows.getCurrent({populate: true}); getting.then(setTitle, setTitleError); }); diff --git a/content.js b/content.js index c384402..bd3785d 100644 --- a/content.js +++ b/content.js @@ -1,11 +1,17 @@ - var infoTitle = document.getElementById('text-section-header'); - infoTitle.textContent = chrome.i18n.getMessage("infoTitle"); +var infoTitle = document.getElementById('text-section-header'); +infoTitle.textContent = chrome.i18n.getMessage("infoTitle"); - var infoMessage = document.getElementById('text-section-helptext'); - infoMessage.textContent = chrome.i18n.getMessage("infoMessage"); +var infoMessage = document.getElementById('text-section-helptext'); +infoMessage.textContent = chrome.i18n.getMessage("infoMessage"); - var helpMessage = document.getElementById('window-create-help-panel'); - helpMessage.textContent = chrome.i18n.getMessage("helpMessage"); +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'); +newsMessage.textContent = chrome.i18n.getMessage("newsMessage"); - var newsMessage = document.getElementById('window-create-news-panel'); - newsMessage.textContent = chrome.i18n.getMessage("newsMessage"); +var clearData = documents.getElementByID("clear-browser-data") +cleardata.textContent = chrome.i18n.getMessage("clearData"); diff --git a/info.js b/info.js index 62ef897..845a070 100644 --- a/info.js +++ b/info.js @@ -40,6 +40,8 @@ document.addEventListener("click", (e) => { } chrome.windows.update(currentWindow.id, updateInfo); }); + }else if (e.target.id === "clear-browser-data") { + forgetBrowsingData() } e.preventDefault(); diff --git a/manifest.json b/manifest.json index 84a71a6..9c3e087 100644 --- a/manifest.json +++ b/manifest.json @@ -5,10 +5,10 @@ "strict_min_version": "60.0" } }, - "permissions": ["theme", "proxy", "privacy", "storage"], + "permissions": ["theme", "browsingData", "notifications", "proxy", "privacy", "storage"], "manifest_version": 2, "name": "__MSG_extensionName__", - "version": "1.21", + "version": "1.23", "description": "__MSG_extensionDescription__", "homepage_url": "https://github.com/eyedeekay/i2psetproxy.js", "icons": { @@ -24,7 +24,7 @@ "page": "options/options.html" }, "background": { - "scripts": ["background.js", "proxy.js", "info.js" ] + "scripts": ["background.js", "proxy.js", "info.js", "privacy.js" ] }, "default_locale": "en" } diff --git a/options/options.js b/options/options.js index 4cfc9dd..343cd94 100644 --- a/options/options.js +++ b/options/options.js @@ -1,4 +1,13 @@ +function isDroid() { + var gettingInfo = browser.runtime.getPlatformInfo(); + gettingInfo.then((got) => { + if (got.os == "android") { + return true + } + }); +} + function SetHostText(){ var hostid = document.getElementById('hostText'); hostid.textContent = chrome.i18n.getMessage("hostText"); @@ -47,7 +56,7 @@ function getPort() { } return proxy_port; } -/* + function getControlHost() { control_host = document.getElementById("controlhost").value console.log("Got i2p control host:", control_host); @@ -65,7 +74,7 @@ function getControlPort() { } return control_port; } -*/ + function isFirefox() { testPlain = navigator.userAgent.indexOf('Firefox') !== -1; if (testPlain) { @@ -106,49 +115,27 @@ function onError(e) { //var controlPort = "7951" //getControlPort(); function setupProxy() { - //var controlHost = getControlHost(); - //var controlPort = getControlPort(); - if (isFirefox()) { - if (getScheme() == "http") { - var proxySettings = { - proxyType: "manual", - http: getHost()+":"+getPort(), - passthrough: "", - httpProxyAll: true - }; - chrome.proxy.settings.set({value:proxySettings}); - console.log("i2p settings created for Firefox") + //var controlHost = getControlHost() + //var controlPort = getControlPort() + var Host = getHost() + var Port = getPort() + console.log("Setting up Firefox Desktop proxy") + var proxySettings = { + proxyType: "manual", + http: Host+":"+Port, + passthrough: "", + httpProxyAll: true + }; + browser.proxy.settings.set({value:proxySettings}); + console.log("i2p settings created for Firefox Desktop") + if (isDroid()) { + console.log("Setting up Firefox Android proxy") + if (Port == "7950") { + browser.proxy.register("android-ext.pac"); + }else{ + browser.proxy.register("android.pac"); } - }else{ - var config = { - mode: "fixed_servers", - rules: { - proxyForHttp: { - scheme: getScheme(), - host: getHost(), - port: getPort() - }, - proxyForFtp: { - scheme: getScheme(), - host: getHost(), - port: getPort() - }, - proxyForHttps: { - scheme: getScheme(), - host: getHost(), - port: getPort() - }, - fallbackProxy: { - scheme: getScheme(), - host: getHost(), - port: getPort() - } - } - }; - chrome.proxy.settings.set( - {value: config, scope: 'regular'}, - function() {}); - console.log("i2p settings created for Chromium") + console.log("i2p settings created for Firefox Android") } } @@ -205,12 +192,10 @@ function updateUI(restoredSettings) { function onError(e) { console.error(e); } - -const assureStoredSettings = chrome.storage.local.get(); -assureStoredSettings.then(checkStoredSettings, onError); - -const gettingStoredSettings = chrome.storage.local.get(); -gettingStoredSettings.then(updateUI, onError); +chrome.storage.local.get(function(got){ + checkStoredSettings(got) + updateUI(got) +}); const saveButton = document.querySelector("#save-button"); saveButton.addEventListener("click", storeSettings); diff --git a/proxy.js b/proxy.js index aa96eaf..aa20ba9 100644 --- a/proxy.js +++ b/proxy.js @@ -1,20 +1,19 @@ function isFirefox() { testPlain = navigator.userAgent.indexOf('Firefox') !== -1; if (testPlain) { + console.log("firefox") return testPlain } - testTorBrowser = navigator.userAgent.indexOf('Tor') !== -1; - if (testTorBrowser) { - return testTorBrowser - } return false } + function isDroid() { - testPlain = navigator.userAgent.indexOf('Android') !== -1; - if (testPlain) { - return testPlain - } - return false + var gettingInfo = browser.runtime.getPlatformInfo(); + gettingInfo.then((got) => { + if (got.os == "android") { + return true + } + }); } if (isFirefox()) { @@ -25,67 +24,37 @@ chrome.privacy.network.webRTCIPHandlingPolicy.set({value: "disable_non_proxied_u console.log("Preliminarily disabled WebRTC.") -var controlHost = "127.0.0.1" //getControlHost() -var controlPort = "7951" //getControlPort(); - - function setupProxy() { - var controlHost = getControlHost(); - var controlPort = getControlPort(); - if (isFirefox()) { - if (isDroid()) { - if (getPort() == "7950") { - browser.proxy.register("android-ext.pac"); - }else{ - browser.proxy.register("android.pac"); - } + var controlHost = "127.0.0.1" //getControlHost() + var controlPort = "7951" //getControlPort(); + var Host = getHost() + var Port = getPort() + console.log("Setting up Firefox Desktop proxy") + var proxySettings = { + proxyType: "manual", + http: Host+":"+Port, + passthrough: "", + httpProxyAll: true + }; + browser.proxy.settings.set({value:proxySettings}); + console.log("i2p settings created for Firefox Desktop") + if (isDroid()) { + console.log("Setting up Firefox Android proxy") + if (Port == "7950") { + browser.proxy.register("android-ext.pac"); }else{ - if (getScheme() == "http") { - var proxySettings = { - proxyType: "manual", - http: getHost()+":"+getPort(), - passthrough: "", - httpProxyAll: true - }; - chrome.proxy.settings.set({value:proxySettings}); - console.log("i2p settings created for Firefox") - } + browser.proxy.register("android.pac"); } - }else{ - var config = { - mode: "fixed_servers", - rules: { - proxyForHttp: { - scheme: getScheme(), - host: getHost(), - port: getPort() - }, - proxyForFtp: { - scheme: getScheme(), - host: getHost(), - port: getPort() - }, - proxyForHttps: { - scheme: getScheme(), - host: getHost(), - port: getPort() - }, - fallbackProxy: { - scheme: getScheme(), - host: getHost(), - port: getPort() - } - } - }; - chrome.proxy.settings.set( - {value: config, scope: 'regular'}, - function() {}); - console.log("i2p settings created for Chromium") + console.log("i2p settings created for Firefox Android") } } - if (isFirefox()){ // Theme all currently open windows browser.windows.getAll().then(wins => wins.forEach(themeWindow)); } + +if (isFirefox()) { + setAllPrivacy() + setupProxy() +} diff --git a/window.html b/window.html index a2568d4..247438e 100644 --- a/window.html +++ b/window.html @@ -23,16 +23,19 @@
- - - - Open the Help
- Visit the I2P News
- + + + + Clear all browsing data
+ +
+ Visit the I2P Forums
+ Get the latest I2P News
+