diff --git a/src/css/popup.css b/src/css/popup.css index 56913fd..42311cb 100644 --- a/src/css/popup.css +++ b/src/css/popup.css @@ -1490,7 +1490,7 @@ manage things like container crud */ } #edit-container-panel-choose-icon .radio-container:hover .usercontext-icon::before { - fill: #fff !important; + fill: var(--grey50) !important; } .mac-icon { @@ -2182,4 +2182,8 @@ tr:hover > td > .trash-button { .radio-choice > .radio-container > [type="radio"]:checked + label { background: var(--bgDark); } + + #edit-container-panel-choose-icon .radio-container:hover .usercontext-icon::before { + fill: #fff !important; + } } diff --git a/src/js/background/backgroundLogic.js b/src/js/background/backgroundLogic.js index 4ee2394..05cad39 100644 --- a/src/js/background/backgroundLogic.js +++ b/src/js/background/backgroundLogic.js @@ -55,23 +55,13 @@ const backgroundLogic = { }, async createOrUpdateContainer(options) { - let donePromise; if (options.userContextId !== "new") { - donePromise = browser.contextualIdentities.update( + return await browser.contextualIdentities.update( this.cookieStoreId(options.userContextId), options.params ); - } else { - donePromise = browser.contextualIdentities.create(options.params); - // We cannot yet access the new cookieStoreId via this.cookieStoreId(...), so we take this from the resolved promise - donePromise.then((identity) => { - (identity.cookieStoreId, options.proxy); - }).catch(() => { - // Empty because this should never happen theoretically. - }); } - - await donePromise; + return await browser.contextualIdentities.create(options.params); }, async openNewTab(options) { diff --git a/src/js/mozillaVpn.js b/src/js/mozillaVpn.js index 6514771..e22069c 100644 --- a/src/js/mozillaVpn.js +++ b/src/js/mozillaVpn.js @@ -12,6 +12,10 @@ const MozillaVPN = { for (const el of document.querySelectorAll("[data-cookie-store-id]")) { const cookieStoreId = el.dataset.cookieStoreId; + + if (!proxies[cookieStoreId]) { + continue; + } const { proxy } = proxies[cookieStoreId]; if (typeof(proxy) !== "undefined") { @@ -139,7 +143,7 @@ const MozillaVPN = { return proxies; }, - getMozillaProxyInfoObj () { + getMozillaProxyInfoObj() { return { countryCode: undefined, cityName: undefined, @@ -211,7 +215,7 @@ const MozillaVPN = { return `socks://${socksName}.mullvad.net:1080`; }, - async pickRandomServer() { + async pickRandomLocation() { const { mozillaVpnServers } = await browser.storage.local.get("mozillaVpnServers"); const randomInteger = this.getRandomInteger(0, mozillaVpnServers.length - 1); const randomServerCountry = mozillaVpnServers[randomInteger]; diff --git a/src/js/popup.js b/src/js/popup.js index ef3667b..55f7a3c 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -1474,7 +1474,7 @@ Logic.registerPanel(P_CONTAINER_EDIT, { } else { // No saved Mozilla VPN proxy information. Get something new. - const { randomServerCountryCode, randomServerCityName } = await MozillaVPN.pickRandomServer(); + const { randomServerCountryCode, randomServerCityName } = await MozillaVPN.pickRandomLocation(); proxy = MozillaVPN.getProxy( randomServerCountryCode, diff --git a/src/js/proxified-containers.js b/src/js/proxified-containers.js index 44845bb..3fdcf30 100644 --- a/src/js/proxified-containers.js +++ b/src/js/proxified-containers.js @@ -3,19 +3,12 @@ proxifiedContainers = { // Slightly modified version of 'retrieve' which returns a direct proxy whenever an error is met. async retrieveFromBackground(cookieStoreId = null) { - return new Promise((resolve, reject) => { - proxifiedContainers.retrieve(cookieStoreId).then((success) => { - // TODO consider better methods of handling containers with MozillaVPN proxy - // configs when MozillaVPN is not connected. Currently we are only messaging this - // in the main panel. - // if (mozProxyIsEnabled && !mozillaVpnConnected) { something better here ? } - resolve(success.proxy); - }, function() { - resolve(Utils.DEFAULT_PROXY); - }).catch((error) => { - reject(error); - }); - }); + try { + const success = await proxifiedContainers.retrieve(cookieStoreId); + return success.proxy; + } catch (e) { + return Utils.DEFAULT_PROXY; + } }, report_proxy_error(error, identifier = null) { @@ -66,53 +59,40 @@ proxifiedContainers = { }); }, - set(cookieStoreId, proxy, initialize = false) { - return new Promise((resolve, reject) => { - if (initialize === true) { - const proxifiedContainersStore = []; - proxifiedContainersStore.push({ - cookieStoreId: cookieStoreId, - proxy: proxy - }); - - browser.storage.local.set({ - proxifiedContainersKey: proxifiedContainersStore - }); - - - resolve(proxy); - } - - // Assumes proxy is a properly formatted object - proxifiedContainers.retrieve().then((proxifiedContainersStore) => { - let index = proxifiedContainersStore.findIndex(i => i.cookieStoreId === cookieStoreId); - - if (index === -1) { - proxifiedContainersStore.push({ - cookieStoreId: cookieStoreId, - proxy: proxy - }); - index = proxifiedContainersStore.length - 1; - } else { - proxifiedContainersStore[index] = { - cookieStoreId: cookieStoreId, - proxy: proxy - }; - } - - browser.storage.local.set({ - proxifiedContainersKey: proxifiedContainersStore - }); - - resolve(proxifiedContainersStore[index]); - }, (errorObj) => { - reject(errorObj); - }).catch((error) => { - throw error; + async set(cookieStoreId, proxy, initialize = false) { + if (initialize === true) { + const proxifiedContainersStore = []; + proxifiedContainersStore.push({ + cookieStoreId: cookieStoreId, + proxy: proxy }); + await browser.storage.local.set({ + proxifiedContainersKey: proxifiedContainersStore + }); + return proxy; + } + // Assumes proxy is a properly formatted object + const proxifiedContainersStore = await proxifiedContainers.retrieve(); + let index = proxifiedContainersStore.findIndex(i => i.cookieStoreId === cookieStoreId); + if (index === -1) { + proxifiedContainersStore.push({ + cookieStoreId: cookieStoreId, + proxy: proxy + }); + index = proxifiedContainersStore.length - 1; + } else { + proxifiedContainersStore[index] = { + cookieStoreId: cookieStoreId, + proxy: proxy + }; + } + await browser.storage.local.set({ + proxifiedContainersKey: proxifiedContainersStore }); + return proxifiedContainersStore[index]; }, + //Parses a proxy description string of the format type://host[:port] or type://username:password@host[:port] (port is optional) parseProxy(proxy_str, mozillaVpnData = null) { const proxyRegexp = /(?(https?)|(socks4?)):\/\/(\b(?\w+):(?\w+)@)?(?((?:\d{1,3}\.){3}\d{1,3}\b)|(\b([\w.-]+)(\.([\w.-]+))+))(:(?\d+))?/; @@ -133,26 +113,15 @@ proxifiedContainers = { }, // Deletes the proxy information object for a specified cookieStoreId [useful for cleaning] - delete(cookieStoreId) { - return new Promise((resolve, reject) => { - // Assumes proxy is a properly formatted object - proxifiedContainers.retrieve().then((proxifiedContainersStore) => { - const index = proxifiedContainersStore.findIndex(i => i.cookieStoreId === cookieStoreId); - - if (index !== -1) { - proxifiedContainersStore.splice(index, 1); - } - - browser.storage.local.set({ - proxifiedContainersKey: proxifiedContainersStore - }); - - resolve(); - }, (errorObj) => { - reject(errorObj); - }).catch((error) => { - throw error; - }); + async delete(cookieStoreId) { + // Assumes proxy is a properly formatted object + const proxifiedContainersStore = await proxifiedContainers.retrieve(); + const index = proxifiedContainersStore.findIndex(i => i.cookieStoreId === cookieStoreId); + if (index !== -1) { + proxifiedContainersStore.splice(index, 1); + } + await browser.storage.local.set({ + proxifiedContainersKey: proxifiedContainersStore }); } };