From 2a3e6c736e63038f3a53dcad942719b806148594 Mon Sep 17 00:00:00 2001 From: idk Date: Sat, 16 Mar 2019 11:28:20 -0400 Subject: [PATCH] ad pac file based proxy setting so it can be easy on Android --- Makefile | 2 +- android.pac | 3 +++ background.js | 12 ++++-------- manifest.json | 3 ++- proxy.js | 31 ++++++++++++++++++++++--------- 5 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 android.pac diff --git a/Makefile b/Makefile index 1232608..18f5b81 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ uninstall: clobber: rm -f ../i2psetproxy.js.zip ../i2p_proxy*.xpi -VERSION=1.19 +VERSION=1.21 xpi: mv ~/Downloads/i2p_proxy-$(VERSION)-an+fx.xpi ../i2psetproxy.js@eyedeekay.github.io.xpi diff --git a/android.pac b/android.pac new file mode 100644 index 0000000..e19940a --- /dev/null +++ b/android.pac @@ -0,0 +1,3 @@ +function FindProxyForURL(url, host) { + return "PROXY 127.0.0.1:4444"; +} diff --git a/background.js b/background.js index f9541c6..fad3548 100644 --- a/background.js +++ b/background.js @@ -1,9 +1,5 @@ chrome.windows.onCreated.addListener(themeWindow); -// Theme all currently open windows -//browser.windows.getAll().then(wins => wins.forEach(themeWindow)); - - var titlepref = chrome.i18n.getMessage("titlePreface"); var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate"); @@ -12,10 +8,10 @@ function themeWindow(window) { if (window.incognito) { chrome.theme.update(window.id, { images: { - headerURL: "icons/toopie.png", + theme_frame: "icons/toopie.png", }, colors: { - accentcolor: "#A0A0DE", + frame: "#A0A0DE", textcolor: "white", toolbar: "#A0A0DE", toolbar_text: "white" @@ -28,10 +24,10 @@ function themeWindow(window) { else { chrome.theme.update(window.id, { images: { - headerURL: "icons/toopie.png", + theme_frame: "icons/toopie.png", }, colors: { - accentcolor: "#BFA0DE", + frame: "#BFA0DE", textcolor: "white", toolbar: "#BFA0DE", toolbar_text: "white" diff --git a/manifest.json b/manifest.json index 1d7c0df..ad71aee 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "permissions": ["theme", "proxy", "privacy", "storage"], "manifest_version": 2, "name": "__MSG_extensionName__", - "version": "1.19", + "version": "1.20", "description": "__MSG_extensionDescription__", "homepage_url": "https://github.com/eyedeekay/i2psetproxy.js", "icons": { @@ -28,3 +28,4 @@ }, "default_locale": "en" } + diff --git a/proxy.js b/proxy.js index 5b865ba..c92b7e4 100644 --- a/proxy.js +++ b/proxy.js @@ -9,6 +9,14 @@ function isFirefox() { } return false } +function isDroid() { + testPlain = navigator.userAgent.indexOf('Android') !== -1; + if (testPlain) { + return testPlain + } + return false +} + if (isFirefox()) { browser.privacy.network.peerConnectionEnabled.set({value: false}); } @@ -20,19 +28,24 @@ 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 (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") + if (isDroid()) { + browser.proxy.register("android.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") + } } }else{ var config = {