diff --git a/extensions/chromium/minimalistic-pac-setter/.eslintrc.js b/extensions/chromium/.eslintrc.js similarity index 95% rename from extensions/chromium/minimalistic-pac-setter/.eslintrc.js rename to extensions/chromium/.eslintrc.js index bb4f67e..917c5ed 100644 --- a/extensions/chromium/minimalistic-pac-setter/.eslintrc.js +++ b/extensions/chromium/.eslintrc.js @@ -13,6 +13,7 @@ module.exports = { }, "parserOptions": { "sourceType": "script", + "ecmaVersion": 2017, "ecmaFeatures": { "impliedStrict": false } diff --git a/extensions/chromium/minimalistic-pac-setter/Support.md b/extensions/chromium/minimalistic-pac-setter/Support.md deleted file mode 100755 index 0c771c0..0000000 --- a/extensions/chromium/minimalistic-pac-setter/Support.md +++ /dev/null @@ -1 +0,0 @@ -# Перемещено [сюда](https://rebrand.ly/ac-support) diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/_ext-error-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/_ext-error-128.png deleted file mode 100644 index 76a65ab..0000000 Binary files a/extensions/chromium/minimalistic-pac-setter/extension/icons/_ext-error-128.png and /dev/null differ diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/_no-control-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/_no-control-128.png deleted file mode 100644 index 8256c6d..0000000 Binary files a/extensions/chromium/minimalistic-pac-setter/extension/icons/_no-control-128.png and /dev/null differ diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/_pac-error-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/_pac-error-128.png deleted file mode 100644 index 15684ce..0000000 Binary files a/extensions/chromium/minimalistic-pac-setter/extension/icons/_pac-error-128.png and /dev/null differ diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/ext-error-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/ext-error-128.png deleted file mode 100644 index 8bb4857..0000000 Binary files a/extensions/chromium/minimalistic-pac-setter/extension/icons/ext-error-128.png and /dev/null differ diff --git a/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.js b/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.js deleted file mode 100755 index 9713bb7..0000000 --- a/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.js +++ /dev/null @@ -1,215 +0,0 @@ -'use strict'; - -chrome.runtime.getBackgroundPage( (backgroundPage) => - backgroundPage.apis.errorHandlers.installListenersOnAsync(window, 'POPUP', () => { - - const getStatus = () => document.querySelector('#status'); - - const setStatusTo = (msg) => { - - getStatus().innerHTML = msg; - - }; - - const antiCensorRu = backgroundPage.apis.antiCensorRu; - const errorHandlers = backgroundPage.apis.errorHandlers; - - // SET DATE - - const setDate = () => { - - let dateForUser = 'никогда'; - if( antiCensorRu.lastPacUpdateStamp ) { - let diff = Date.now() - antiCensorRu.lastPacUpdateStamp; - let units = 'мс'; - const gauges = [ - [1000, 'с'], - [60, 'мин'], - [60, 'ч'], - [24, 'дн'], - [7, ' недель'], - [4, ' месяцев'], - ]; - for(const g of gauges) { - const diffy = Math.floor(diff / g[0]); - if (!diffy) - break; - diff = diffy; - units = g[1]; - } - dateForUser = diff + units + ' назад'; - } - - const dateElement = document.querySelector('.update-date'); - dateElement.innerText = dateForUser + ' / ' + (antiCensorRu.pacUpdatePeriodInMinutes/60) + 'ч'; - dateElement.title = new Date(antiCensorRu.lastPacUpdateStamp) - .toLocaleString('ru-RU'); - - }; - - setDate(); - chrome.storage.onChanged.addListener( - (changes) => changes.lastPacUpdateStamp.newValue && setDate() - ); - - // CLOSE BUTTON - - document.querySelector('.close-button').onclick = () => window.close(); - - // RADIOS - - const currentProviderRadio = () => { - - const id = antiCensorRu.currentPacProviderKey || 'none'; - return document.querySelector('#'+id); - - }; - const checkChosenProvider = () => currentProviderRadio().checked = true; - - const showError = (err) => { - - let clarification = err.clarification; - const ifNotCritical = clarification && clarification.ifNotCritical; - let message = err.message || ''; - - while( clarification ) { - message = (clarification && (clarification.message + ' ')) + message; - clarification = clarification.prev; - } - message = message.trim(); - setStatusTo( - ` - ${ifNotCritical ? 'Некритичная ошибка.' : 'Ошибка!'} - -
- ${message} - - [Ещё подробнее] - ` - ); - getStatus().querySelector('.link-button').onclick = function() { - - errorHandlers.viewErrorVoid(err); - return false; - - }; - - }; - - const enableDisableInputs = function() { - - const inputs = document.querySelectorAll('input'); - for ( let i = 0; i < inputs.length; i++ ) { - inputs[i].disabled = !inputs[i].disabled; - } - - }; - - const conduct = (beforeStatus, operation, afterStatus, onSuccess) => { - - setStatusTo(beforeStatus); - enableDisableInputs(); - operation((err) => { - if (err) { - showError(err); - } else { - setStatusTo(afterStatus); - onSuccess && onSuccess(); - } - enableDisableInputs(); - }); - - }; - - const ul = document.querySelector('#list-of-providers'); - const _firstChild = ul.firstChild; - for( const providerKey of Object.keys(antiCensorRu.pacProviders).sort() ) { - const li = document.createElement('li'); - li.innerHTML = ` - - - [обновить]`; - li.querySelector('.link-button').onclick = - () => { - conduct( - 'Обновляем...', (cb) => antiCensorRu.syncWithPacProviderAsync(cb), - 'Обновлено.' - ); - return false; - }; - ul.insertBefore( li, _firstChild ); - } - checkChosenProvider(); - - const radios = [].slice.apply( - document.querySelectorAll('[name=pacProvider]') - ); - for(const radio of radios) { - radio.onclick = function(event) { - - if ( - event.target.id === (antiCensorRu.currentPacProviderKey || 'none') - ) { - return false; - } - const pacKey = event.target.id; - if (pacKey === 'none') { - conduct( - 'Отключение...', - (cb) => antiCensorRu.clearPacAsync(cb), - 'Отключено.', - checkChosenProvider - ); - } else { - conduct( - 'Установка...', - (cb) => antiCensorRu.installPacAsync(pacKey, cb), - 'PAC-скрипт установлен.', - checkChosenProvider - ); - } - return false; - }; - } - - const conpanel = document.getElementById('list-of-handlers'); - errorHandlers.getEventsMap().forEach( (value, name) => { - - const li = document.createElement('li'); - li.innerHTML = ` - - `; - const box = li.querySelector('input'); - box.checked = backgroundPage.apis.errorHandlers.isOn(name); - box.onclick = function() { - - const id = this.id.replace('if-on-', ''); - return backgroundPage.apis.errorHandlers.switchVoid( - this.checked ? 'on' : 'off', - id - ); - - }; - conpanel.appendChild(li); - - }); - - if( errorHandlers.ifNotControlled ) { - document.getElementById('which-extension').innerHTML = backgroundPage.utils.messages.whichExtensionHtml(); - document.querySelectorAll('.if-not-controlled').forEach( (node) => { - - node.style.display = 'block'; - - }); - } - setStatusTo(''); - - if (antiCensorRu.ifFirstInstall) { - const id = antiCensorRu.currentPacProviderKey || 'none'; - document.querySelector('#update-' + id).click(); - } - document.documentElement.style.display = ''; - - }) -); diff --git a/extensions/chromium/minimalistic-pac-setter/package.json b/extensions/chromium/package.json similarity index 83% rename from extensions/chromium/minimalistic-pac-setter/package.json rename to extensions/chromium/package.json index 7e06e92..304b924 100644 --- a/extensions/chromium/minimalistic-pac-setter/package.json +++ b/extensions/chromium/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "lint": "./node_modules/.bin/eslint ./extension/**/*.js --ignore-pattern vendor" + "lint": "./node_modules/.bin/eslint ./runet-censorship-bypass/extension/**/*.js --ignore-pattern vendor" }, "author": "Ilya Ig. Petrov", "license": "GPLv3", diff --git a/extensions/chromium/minimalistic-pac-setter/README.md b/extensions/chromium/runet-censorship-bypass/README.md similarity index 100% rename from extensions/chromium/minimalistic-pac-setter/README.md rename to extensions/chromium/runet-censorship-bypass/README.md diff --git a/extensions/chromium/minimalistic-pac-setter/assets-sources.txt b/extensions/chromium/runet-censorship-bypass/assets-sources.txt similarity index 100% rename from extensions/chromium/minimalistic-pac-setter/assets-sources.txt rename to extensions/chromium/runet-censorship-bypass/assets-sources.txt diff --git a/extensions/chromium/minimalistic-pac-setter/extension/00-init-apis.js b/extensions/chromium/runet-censorship-bypass/extension/00-init-apis.js similarity index 100% rename from extensions/chromium/minimalistic-pac-setter/extension/00-init-apis.js rename to extensions/chromium/runet-censorship-bypass/extension/00-init-apis.js diff --git a/extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js b/extensions/chromium/runet-censorship-bypass/extension/11-api-error-handlers.js similarity index 96% rename from extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js rename to extensions/chromium/runet-censorship-bypass/extension/11-api-error-handlers.js index ab5b7af..0f310bd 100644 --- a/extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js +++ b/extensions/chromium/runet-censorship-bypass/extension/11-api-error-handlers.js @@ -122,7 +122,9 @@ this.ifNotControlled = window.utils.areSettingsNotControlledFor(details); if (this.ifNotControlled) { - chrome.browserAction.setIcon( {path: './icons/default-grayscale-128.png'} ); + chrome.browserAction.setIcon({ + path: './icons/default-grayscale-128.png', + }); } else { chrome.browserAction.setIcon( {path: './icons/default-128.png'} ); } @@ -201,7 +203,9 @@ chrome.notifications.clear(notId); if(notId === 'no-control') { - return openAndFocus( window.utils.messages.searchSettingsForUrl('proxy') ); + return openAndFocus( + window.utils.messages.searchSettingsForUrl('proxy') + ); } const errors = handlers.idToError; handlers.viewErrorVoid(errors); diff --git a/extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js b/extensions/chromium/runet-censorship-bypass/extension/12-api-sync-pac-script-with-pac-provider.js similarity index 92% rename from extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js rename to extensions/chromium/runet-censorship-bypass/extension/12-api-sync-pac-script-with-pac-provider.js index 3b033a4..ca67ecf 100644 --- a/extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js +++ b/extensions/chromium/runet-censorship-bypass/extension/12-api-sync-pac-script-with-pac-provider.js @@ -113,9 +113,9 @@ /* Don't use in system configs! Because Win does poor caching. Url is encoded to counter abuse. - Version: 0.15 + Version: 0.17 */ - pacUrl: '\x68\x74\x74\x70\x73\x3a\x2f\x2f\x64\x72\x69\x76\x65\x2e\x67\x6f\x6f\x67\x6c\x65\x2e\x63\x6f\x6d\x2f\x75\x63\x3f\x65\x78\x70\x6f\x72\x74\x3d\x64\x6f\x77\x6e\x6c\x6f\x61\x64\x26\x69\x64\x3d\x30\x42\x2d\x5a\x43\x56\x53\x76\x75\x4e\x57\x66\x30\x62\x7a\x4e\x55\x52\x32\x46\x34\x52\x46\x38\x77\x4f\x55\x30', + pacUrl: '\x68\x74\x74\x70\x73\x3a\x2f\x2f\x64\x72\x69\x76\x65\x2e\x67\x6f\x6f\x67\x6c\x65\x2e\x63\x6f\x6d\x2f\x75\x63\x3f\x65\x78\x70\x6f\x72\x74\x3d\x64\x6f\x77\x6e\x6c\x6f\x61\x64\x26\x69\x64\x3d\x30\x42\x2d\x5a\x43\x56\x53\x76\x75\x4e\x57\x66\x30\x54\x44\x46\x52\x4f\x47\x35\x46\x62\x55\x39\x4f\x64\x44\x67', proxyHosts: ['proxy.antizapret.prostovpn.org', 'gw2.anticenz.org'], proxyIps: { '195.123.209.38': 'proxy.antizapret.prostovpn.org', @@ -224,7 +224,7 @@ const pacProvider = this.getPacProvider(key); const pacSetPromise = new Promise( - (resolve, reject) => setPacScriptFromProvider( + (resolve, reject) => setPacScriptFromProviderAsync( pacProvider, (err, res) => { @@ -444,7 +444,10 @@ }); - function setPacAsync(pacData, cb = throwIfError) { + function setPacAsync( + {pacData = mandatory(), pacUrl = mandatory()}, + cb = throwIfError + ) { const config = { mode: 'pac_script', @@ -454,20 +457,44 @@ }, }; console.log('Setting chrome proxy settings...'); - chrome.proxy.settings.set( {value: config}, () => { + chrome.proxy.settings.set( {value: config}, async () => { - const err = checkChromeError(); + let err = checkChromeError(); + let asciiErr; if (err) { - return cb(err); + if (err.message.startsWith('\'pacScript.data\' supports only ASCII')) { + asciiErr = err; + asciiErr.clarification = {ifNotCritical: true}; + err = await new Promise((resolve) => { + + chrome.proxy.settings.set({ + value: { + mode: 'pac_script', + pacScript: { + url: pacUrl, + }, + }, + }, + () => resolve( checkChromeError() ) + ); + + }); + + } + if (err) { + return cb(err); + } } chrome.proxy.settings.get({}, (details) => { if ( window.utils.areSettingsNotControlledFor( details ) ) { console.warn('Failed, other extension is in control.'); - return cb({clarification: {message: window.utils.messages.whichExtensionHtml() }}); + return cb({clarification: { + message: window.utils.messages.whichExtensionHtml(), + }}); } console.log('Successfuly set PAC in proxy settings..'); - cb(); + cb(asciiErr); }); }); @@ -606,15 +633,16 @@ } - function setPacScriptFromProvider(provider, cb = throwIfError) { + function setPacScriptFromProviderAsync(provider, cb = throwIfError) { cb = asyncLogGroup( 'Getting pac script from provider...', provider.pacUrl, cb ); + const pacUrl = provider.pacUrl; httpGet( - provider.pacUrl, + pacUrl, (err, pacData) => { if (err) { @@ -625,7 +653,7 @@ }; return cb(err); } - setPacAsync(pacData, cb); + setPacAsync({pacData, pacUrl}, cb); } ); diff --git a/extensions/chromium/minimalistic-pac-setter/extension/20-api-fixes.js b/extensions/chromium/runet-censorship-bypass/extension/20-api-fixes.js similarity index 100% rename from extensions/chromium/minimalistic-pac-setter/extension/20-api-fixes.js rename to extensions/chromium/runet-censorship-bypass/extension/20-api-fixes.js diff --git a/extensions/chromium/minimalistic-pac-setter/extension/30-block-informer.js b/extensions/chromium/runet-censorship-bypass/extension/30-block-informer.js similarity index 100% rename from extensions/chromium/minimalistic-pac-setter/extension/30-block-informer.js rename to extensions/chromium/runet-censorship-bypass/extension/30-block-informer.js diff --git a/extensions/chromium/minimalistic-pac-setter/extension/40-context-menus.js b/extensions/chromium/runet-censorship-bypass/extension/40-context-menus.js similarity index 67% rename from extensions/chromium/minimalistic-pac-setter/extension/40-context-menus.js rename to extensions/chromium/runet-censorship-bypass/extension/40-context-menus.js index 222bce4..2db6a12 100644 --- a/extensions/chromium/minimalistic-pac-setter/extension/40-context-menus.js +++ b/extensions/chromium/runet-censorship-bypass/extension/40-context-menus.js @@ -12,12 +12,18 @@ createMenuLinkEntry( 'Сайт доступен из-за границы? Is up?', - (tab) => 'http://isup.me/' + new URL(tab.url).hostname + (tab) => `data:text/html;charset=utf8,Запрашиваю... +
+ +
+