diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js index eaa2f25..a45d442 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js @@ -634,8 +634,8 @@ ${ if (ifNothingToCook) { return originalSet(details, cb); } - const getPacData = (cb) => - pac.data ? cb(null, pac.data) : window.apis.httpLib.get(autoConfigUrl, cb); + const getPacData = (getPacCb) => + pac.data ? getPacCb(null, pac.data) : window.apis.httpLib.get(autoConfigUrl, getPacCb); getPacData((err, pacData) => { if (err) { @@ -644,27 +644,27 @@ ${ } const pacMods = getCurrentConfigs(); const cookedData = pacKitchen.cook( pacData, pacMods ); + const setCb = (/* No args. */) => { + + kitchenState(ifIncontinence, null); + cb && cb(); + + }; if (window.apis.platform.ifFirefox) { const autoConfigUrl = URL.createObjectURL(new Blob([cookedData], { type: 'application/x-ns-proxy-autoconfig', })); - originalSet({ + return originalSet({ value: { proxyType: 'autoConfig', autoConfigUrl, }, - }, chromified(cb)); - return; + }, setCb); } details.value.pacScript.data = cookedData; - originalSet({value: details.value}, (/* No args. */) => { - - kitchenState(ifIncontinence, null); - cb && cb(); - - }); + return originalSet({ value: details.value }, setCb); }); }; diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js index a2bf9eb..c3789fd 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js @@ -66,12 +66,15 @@ return; } delete settings.levelOfControl; - const setProxyAsync = () => new Promise((setResolve, setReject) => + const setProxyAsync = () => new Promise((setResolve, setReject) => { + + console.log('Restoring chrome proxy settings...'); chrome.proxy.settings.set( settings, chromified((err) => err ? setReject(err) : setResolve()), - ), - ); + ); + }); + console.log('Clearing chrome proxy settings...'); chrome.proxy.settings.clear({}, chromified((clearErr) => { if (clearErr) { reject(clearErr); @@ -86,41 +89,35 @@ pacData = mandatory(), cb = throwIfError, ) { - console.log('Clearing chrome proxy settings...'); - chrome.proxy.settings.clear({}, chromified((clearErr) => { + const config = { + mode: 'pac_script', + pacScript: { + mandatory: false, + data: pacData, + }, + }; + console.log('Setting chrome proxy settings...'); + chrome.proxy.settings.set( { value: config }, chromified((err) => { - if (clearErr) { - return cb(clearErr); + console.log('ERRORR?:', err); + if (err) { + return cb(err); } - const config = { - mode: 'pac_script', - pacScript: { - mandatory: false, - data: pacData, - }, - }; - console.log('Setting chrome proxy settings...'); - chrome.proxy.settings.set( { value: config }, chromified((err) => { + handlers.updateControlState( () => { + + if ( !handlers.ifControlled ) { + + console.warn('Failed, other extension is in control.'); + return cb( + new Error( window.utils.messages.whichExtensionHtml() ), + ); - if (err) { - return cb(err); } - handlers.updateControlState( () => { + console.log('Successfuly set PAC in proxy settings.'); + cb(); - if ( !handlers.ifControlled ) { + }); - console.warn('Failed, other extension is in control.'); - return cb( - new Error( window.utils.messages.whichExtensionHtml() ), - ); - - } - console.log('Successfuly set PAC in proxy settings..'); - cb(); - - }); - - })); })); }; @@ -186,7 +183,15 @@ ), ), Promise.reject(), - ), + )/* + .catch( + clarifyThen( + chrome.i18n.getMessage('FailedToDownloadPacScriptFromAddresses') + ': [ ' + + provider.pacUrls.join(' , ') + ' ].', + cb, + ), + ) + */ ); pacDataPromise.then( @@ -200,7 +205,6 @@ Object.assign(res || {}, {lastModified: lastModifiedStr}), ), ); - }, clarifyThen( @@ -208,7 +212,6 @@ + provider.pacUrls.join(' , ') + ' ].', cb, ), - ); }; @@ -540,7 +543,7 @@ 'Periodic PAC update triggered:', new Date().toLocaleString('ru-RU'), ); - antiCensorRu.syncWithPacProviderAsync(() => {/* swallow */}); + antiCensorRu.syncWithPacProviderAsync(() => { /* Swallow. */ }); } }) @@ -564,7 +567,8 @@ // INSTALL console.log('Installing...'); handlers.switch('on', 'ext-error'); - return chrome.runtime.openOptionsPage(); + chrome.runtime.openOptionsPage(); + return; } // LAUNCH, RELOAD, UPDATE