From f6b8fd0017ed8c8003c50d7c0a42a23c69b8b67e Mon Sep 17 00:00:00 2001 From: Richard Neomy Date: Fri, 20 Apr 2018 18:58:58 +0430 Subject: [PATCH] run proxyConfig.clear before proxyConfig.set --- webextension/common.js | 14 +++++++++++++- webextension/data/.DS_Store | Bin 6148 -> 6148 bytes webextension/data/panel/firefox-proxy.js | 8 +++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/webextension/common.js b/webextension/common.js index 9f2b8aa..ee0fcbe 100644 --- a/webextension/common.js +++ b/webextension/common.js @@ -63,7 +63,19 @@ function icon(config) { if (/Firefox/.test(navigator.userAgent)) { chrome.storage.onChanged.addListener(ps => { if (ps['ffcurent']) { - icon(ps['ffcurent'].newValue); + browser.browserSettings.proxyConfig.get({}).then(settings => { + const mode = { + 'none': 'direct', + 'autoDetect': 'auto_detect', + 'system': 'system', + 'manual': 'fixed_servers', + 'autoConfig': 'pac_script' + }[settings.value.proxyType]; + // overwrite the mode to make sure we are displaying the actual proxy mode; + ps['ffcurent'].newValue.value.mode = mode; + + icon(ps['ffcurent'].newValue); + }); } }); chrome.storage.local.get({ diff --git a/webextension/data/.DS_Store b/webextension/data/.DS_Store index 38b3bc8fa98828b57db5e94416f3f517a920a82d..ff4628c7a0dc23fe7044d9a3708b3d1e4a99bece 100644 GIT binary patch delta 25 gcmZoMXffEZf|bM4)I>+Y(Aa$PMi#lv=UB~z0A-H{ivR!s delta 25 gcmZoMXffEZf|bM6(o9Fe(8O}`Mi#lv=UB~z0A chrome.proxy.callbacks.push(c) }; - chrome.proxy.settings.set = (config, callback = function() {}) => { + chrome.proxy.settings.set = async(config, callback = function() {}) => { const proxySettings = {}; if (config.value.mode === 'direct') { @@ -83,6 +83,7 @@ if (/Firefox/.test(navigator.userAgent)) { proxySettings.autoConfigUrl = config.value.pacScript.url; } // console.log(proxySettings); + await browser.browserSettings.proxyConfig.clear({}); browser.browserSettings.proxyConfig.set({value: proxySettings}, () => { const lastError = chrome.runtime.lastError; if (chrome.runtime.lastError) { @@ -90,10 +91,11 @@ if (/Firefox/.test(navigator.userAgent)) { } }); - chrome.storage.local.set({ + await browser.storage.local.set({ 'ffcurent': { value: config.value } - }, callback); + }); + callback(); }; }