From 3e89c372b9cd48a569089c3c56598f526f80f312 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Fri, 12 Feb 2016 21:00:40 +0500 Subject: [PATCH] changed name, -bugs: migration & alarms --- .../extnesion/block-informer.js | 2 +- .../extnesion/icons/ribbon32.png | Bin 901 -> 0 bytes .../extnesion/manifest.json | 2 +- .../pages/choose-pac-provider/index.js | 4 +- .../sync-pac-script-with-pac-provider.js | 65 ++++++++++-------- 5 files changed, 38 insertions(+), 35 deletions(-) delete mode 100755 extensions/chromium/minimalistic-pac-setter/extnesion/icons/ribbon32.png diff --git a/extensions/chromium/minimalistic-pac-setter/extnesion/block-informer.js b/extensions/chromium/minimalistic-pac-setter/extnesion/block-informer.js index 78a9316..9dddc31 100755 --- a/extensions/chromium/minimalistic-pac-setter/extnesion/block-informer.js +++ b/extensions/chromium/minimalistic-pac-setter/extnesion/block-informer.js @@ -9,7 +9,7 @@ It pertains not only to page refesh but to newly opened pages too. Also on loosing title see: https://github.com/ilyaigpetrov/repository-for-chrome-bugs/blob/master/browserAction-title-lost-after-setting/background.js - Crazy concurrent Chrome. + Crazy parallel Chrome. **/ window.onTabUpdated = {}; diff --git a/extensions/chromium/minimalistic-pac-setter/extnesion/icons/ribbon32.png b/extensions/chromium/minimalistic-pac-setter/extnesion/icons/ribbon32.png deleted file mode 100755 index 4133d5502cd92a89f0e3e6ed418f02178d7c89bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 901 zcmV;01A6?4P)035Jy2rp-nd(ra5&|-a6+{RaP#HHpaJV^-KKD+;;he6n?*H$< zPj^)}s9Bs3(}8(FColnc2aE+?122HTOyz0nc#RssQ-RCCq6GIpP37a1amOS8Z+1RB z1RO9wk?+gcx6k>oq-6qe)~7PSnn>X1_}&2g(2fE>0UhysGjJjS{FSNnIUhzyeCmAo zrZxfRLkG~EF>N%JA)vp4z`^+5ma%PbMS)eo#7upT^Ib8KDCha;x4sbuNS1JiSw=G0Z7v%tQ` z`S4Kz_)4IN+;Ck2|CY4`OpvaJ0EtK%5q>Rq1y%L!_Kyr!1?eAa1EG}F@I(%zdIj>6U9?g+1g4* z^c`@w2^?T#ZRaKu@Xm)nVme=~fb(Gra1WSOu`?PmEDzTBk2jf0U!eldhqb^zRp8P0 zS-gPkt3lv5=fk;N1)L89z_OYbr6Z=Y&-ri`__Ai-9#c8qh~US7T~Ye~fbsEp1Iz@b zh-{dCi8Jq>B;duoD+Q3n97xcvB#tk z7$2`%lSa}pQ`uSK-g~}withjerm{CNczqS4 bXC;C6DHH*am1v|J00000NkvXXu0mjfvR9k@ diff --git a/extensions/chromium/minimalistic-pac-setter/extnesion/manifest.json b/extensions/chromium/minimalistic-pac-setter/extnesion/manifest.json index fd778bd..f0d6208 100755 --- a/extensions/chromium/minimalistic-pac-setter/extnesion/manifest.json +++ b/extensions/chromium/minimalistic-pac-setter/extnesion/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, - "name": "Ненавязчивый РосКомНадзор NEW", + "name": "Обход блокировок Рунета", "description": "Аргументы против цензуры: https://git.io/vEkI9", "version": "0.0.0.10", "icons": { diff --git a/extensions/chromium/minimalistic-pac-setter/extnesion/pages/choose-pac-provider/index.js b/extensions/chromium/minimalistic-pac-setter/extnesion/pages/choose-pac-provider/index.js index dbf208b..da0d498 100755 --- a/extensions/chromium/minimalistic-pac-setter/extnesion/pages/choose-pac-provider/index.js +++ b/extensions/chromium/minimalistic-pac-setter/extnesion/pages/choose-pac-provider/index.js @@ -18,10 +18,8 @@ function renderPage() { status.classList.add('off'); } - console.log('ABC'); chrome.runtime.getBackgroundPage( backgroundPage => { - backgroundPage.console.log('Options page opened.'); var antiCensorRu = backgroundPage.antiCensorRu; // SET DATE @@ -129,7 +127,7 @@ function renderPage() { chrome://extensions › Это расширение › Отладка страниц: фоновая страница › Console (DevTools)'; getStatus().replaceChild(div, this); div.querySelector('.ext').onclick = () => { - chrome.tabs.create({ url: "chrome://extensions" }); + chrome.tabs.create({ url: 'chrome://extensions?id='+ chrome.runtime.id }); return false; } return false; diff --git a/extensions/chromium/minimalistic-pac-setter/extnesion/sync-pac-script-with-pac-provider.js b/extensions/chromium/minimalistic-pac-setter/extnesion/sync-pac-script-with-pac-provider.js index 6ce4d44..b27ce53 100755 --- a/extensions/chromium/minimalistic-pac-setter/extnesion/sync-pac-script-with-pac-provider.js +++ b/extensions/chromium/minimalistic-pac-setter/extnesion/sync-pac-script-with-pac-provider.js @@ -1,13 +1,12 @@ 'use strict'; /* - Task 1. Gets IP for host proxy.antizapret.prostovpn.org with dns-lg.com. - This IP is used in block-informer to inform user when proxy is ON. - Task 2. Downloads PAC proxy script from Antizapret and sets it in Chromium settings. - Task 3. Schedules tasks 1 & 2 for every 2 hours. + Task 1. Gets IPs for proxies of antizapret/anticenz with dns-lg.com. + These IPs are used in block-informer to inform user when proxy is ON. + Task 2. Downloads PAC proxy script from antizapret/anticenz/my Google Drive and sets it in Chromium settings. + Task 3. Schedules tasks 1 & 2 for every 4 hours. */ - /* In background scripts use window.antiCensorRu public variables. In pages window.antiCensorRu are not accessible, @@ -64,7 +63,6 @@ window.antiCensorRu = { lastPacUpdateStamp: 0, // PROTECTED - _periodicUpdateAlarmReason: 'Периодичное обновление PAC-скрипта Антизапрет', pushToStorage(cb) { @@ -98,6 +96,8 @@ window.antiCensorRu = { syncWithPacProvider(cb) { var cb = cb || (() => {}); + if (!this.pacProvider) + return cb({clarification: 'Сперва выберите PAC-провайдера.'}); var pacSetPromise = new Promise( (resolve, reject) => setPacScriptFromProvider( @@ -126,6 +126,13 @@ window.antiCensorRu = { } ); }, + + setAlarms() { + chrome.alarms.create( + this._periodicUpdateAlarmReason, + { periodInMinutes: 4*60 } + ); + }, installPac(key, cb) { @@ -138,11 +145,8 @@ window.antiCensorRu = { this.currentPacProviderKey = key; var cb = asyncLogGroup('Installing PAC...', cb); - - chrome.alarms.create( - this._periodicUpdateAlarmReason, - { periodInMinutes: 4*60 } - ); + + this.setAlarms(); return this.syncWithPacProvider(cb); @@ -167,6 +171,8 @@ window.antiCensorRu = { chrome.storage.local.get(null, oldStorage => { console.log('Init on storage:', oldStorage); + + antiCensorRu.ifFirstInstall = Object.keys(oldStorage).length === 0; // Finish each init with this callback setting alarm listeners. function cb(err) { @@ -183,17 +189,19 @@ chrome.storage.local.get(null, oldStorage => { chrome.alarms.get( antiCensorRu._periodicUpdateAlarmReason, alarm => { - if (!alarm) - return console.error('ALARM NOT SET'); - console.log( - 'Next update is scheduled on', new Date(alarm.scheduledTime).toLocaleString('ru-RU') - ); + if (alarm) + console.log( + 'Next update is scheduled on', new Date(alarm.scheduledTime).toLocaleString('ru-RU') + ); + else if (!antiCensorRu.ifFirstInstall && antiCensorRu.pacProvider) { + antiCensorRu.setAlarms(); + console.error('KNOWN BUG: Alarms were lost. See issues on GitHub. Don\'t worry, next update was rescheduled.'); + } } ); } // INSTALL - antiCensorRu.ifFirstInstall = Object.keys(oldStorage).length === 0; if (antiCensorRu.ifFirstInstall) { console.log('Installing...'); return chrome.runtime.openOptionsPage(cb); @@ -208,7 +216,7 @@ chrome.storage.local.get(null, oldStorage => { // LAUNCH, RELOAD, UPDATE - antiCensorRu._currentPacProviderKey = oldStorage._currentPacProviderKey || antiCensorRu._currentPacProviderKey; + antiCensorRu._currentPacProviderKey = oldStorage._currentPacProviderKey; antiCensorRu.lastPacUpdateStamp = oldStorage.lastPacUpdateStamp || antiCensorRu.lastPacUpdateStamp; if (antiCensorRu.version === oldStorage.version) { @@ -216,16 +224,17 @@ chrome.storage.local.get(null, oldStorage => { console.log('Launch or reload. Do nothing.'); return cb(); } - + // UPDATE & MIGRATION console.log('Updating...'); - return updatePacProxyIps( - antiCensorRu.pacProvider, - ipsError => { - if (ipsError) ipsError.ifNotCritical = true; - antiCensorRu.pushToStorage( pushError => cb( pushError || ipsError ) ); - } - ); + return antiCensorRu.pacProvider && + updatePacProxyIps( + antiCensorRu.pacProvider, + ipsError => { + if (ipsError) ipsError.ifNotCritical = true; + antiCensorRu.pushToStorage( pushError => cb( pushError || ipsError ) ); + } + ); /* @@ -281,10 +290,6 @@ function httpGet(url, cb) { } function updatePacProxyIps(provider, cb) { - if (!provider.proxyHosts) { - console.log(provider+' has no proxies defined.'); - return cb(null, null); - } var cb = asyncLogGroup('Getting IP for '+ provider.proxyHosts.join(', ') +'...', cb); var failure = { clarification: {message:'Не удалось получить один или несколько IP адресов для прокси-серверов. Иконка для уведомления об обходе блокировок может не отображаться.'},