diff --git a/extensions/chromium/minimalistic-pac-setter/extension/00-init-apis.js b/extensions/chromium/minimalistic-pac-setter/extension/00-init-apis.js index 3f9787c..e429962 100644 --- a/extensions/chromium/minimalistic-pac-setter/extension/00-init-apis.js +++ b/extensions/chromium/minimalistic-pac-setter/extension/00-init-apis.js @@ -4,11 +4,30 @@ window.utils = { areSettingsNotControlledFor(details) { - return ['controlled_by_other', 'not_controllable'] + return ['controlled_by_other', 'not_controllable'] .some( (prefix) => details.levelOfControl.startsWith(prefix) ); }, + messages: { + + searchSettingsUrlFor(niddle) { + + return 'chrome://settings/search#' + (chrome.i18n.getMessage(niddle) || niddle); + + }, + + whichExtensionHtml() { + + return chrome.i18n.getMessage('noControl') + + ` + ${ chrome.i18n.getMessage('which') } + `; + + }, + + }, + }; window.apis = {}; diff --git a/extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js b/extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js index dead60c..8346058 100644 --- a/extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js +++ b/extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js @@ -22,6 +22,7 @@ for(const prop in value) { if (/^[A-Z]/.test(prop)) { + console.log(prop); continue; } alt[prop] = value[prop]; @@ -80,7 +81,7 @@ viewError(err) { openAndFocus( - 'https://rebrand.ly/ac-error/?' + JSON.stringify(err, errorJsonReplacer, 0) + 'https://rebrand.ly/ac-error/?' + btoa(JSON.stringify(err, errorJsonReplacer, 0)) ); }, @@ -120,9 +121,9 @@ this.ifNotControlled = window.utils.areSettingsNotControlledFor(details); if (this.ifNotControlled) { - chrome.browserAction.disable(); + chrome.browserAction.setIcon( {path: './icons/default-grayscale-128.png'} ); } else { - chrome.browserAction.enable(); + chrome.browserAction.setIcon( {path: './icons/default-128.png'} ); } return this.ifNotControlled; @@ -150,6 +151,7 @@ requireInteraction: true, type: 'basic', iconUrl: './icons/' + icon, + appIconMaskUrl: './icons/default-mask-128.png', isClickable: true, } ); @@ -186,7 +188,9 @@ const handlers = window.apis.errorHandlers; - // INIT + // INITIALIZATION + // ============== + chrome.proxy.settings.get( {}, (details) => handlers.isNotControlled(details) @@ -196,7 +200,7 @@ chrome.notifications.clear(notId); if(notId === 'no-control') { - return openAndFocus('chrome://settings/#proxy'); + return openAndFocus( window.utils.messages.searchSettingsUrlFor('proxy') ); } const errors = handlers.idToError; handlers.viewError(errors); @@ -230,10 +234,12 @@ console.log('Proxy settings changed.', details); const noCon = 'no-control'; if ( handlers.isNotControlled(details) ) { - console.log(details); - handlers.mayNotify(noCon, 'Другое расширение контролирует прокси', - 'Какое?', - 'no-control-128.png'); + handlers.mayNotify( + noCon, + chrome.i18n.getMessage('noControl'), + chrome.i18n.getMessage('which'), + 'no-control-128.png' + ); } else { chrome.notifications.clear( noCon ); } diff --git a/extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js b/extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js index 05bc2d9..5dfef0f 100644 --- a/extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js +++ b/extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js @@ -109,8 +109,12 @@ }, }, Оба_и_на_свитчах: { - // pacUrl: 'https://drive.google.com/uc?export=download&id=0B-ZCVSvuNWf0akpCOURNS2VCTmc', // 0.14 - pacUrl: 'https://drive.google.com/uc?export=download&id=0B-ZCVSvuNWf0bzNUR2F4RF8wOU0', // 0.15 + /* + Don't use in system configs! Because Win does poor caching. + Url is encoded to counter abuse. + Version: 0.15 + */ + 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', proxyHosts: ['proxy.antizapret.prostovpn.org', 'gw2.anticenz.org'], proxyIps: { '195.123.209.38': 'proxy.antizapret.prostovpn.org', @@ -267,6 +271,11 @@ }, _pacUpdatePeriodInMinutes: 12*60, + get pacUpdatePeriodInMinutes() { + + return this._pacUpdatePeriodInMinutes; + + }, setAlarms() { @@ -454,7 +463,7 @@ if ( window.utils.areSettingsNotControlledFor( details ) ) { console.warn('Failed, other extension is in control.'); - return cb({clarification: {message: 'Настройки прокси контролирует другое расширение. Какое?'}}); + return cb({clarification: {message: window.utils.messages.whichExtensionHtml() }}); } console.log('Successfuly set PAC in proxy settings..'); cb(); diff --git a/extensions/chromium/minimalistic-pac-setter/extension/30-block-informer.js b/extensions/chromium/minimalistic-pac-setter/extension/30-block-informer.js index 93f50cb..9369518 100644 --- a/extensions/chromium/minimalistic-pac-setter/extension/30-block-informer.js +++ b/extensions/chromium/minimalistic-pac-setter/extension/30-block-informer.js @@ -48,8 +48,7 @@ window.tabWithError2ip = {}; // For errors only: Error? -> Check this IP! chrome.webRequest.onErrorOccurred.addListener( (requestDetails) => isInsideTabWithIp(requestDetails) - && isProxiedAndInformed(requestDetails) - , + && isProxiedAndInformed(requestDetails), {urls: ['']} ); diff --git a/extensions/chromium/minimalistic-pac-setter/extension/_locales/en/messages.json b/extensions/chromium/minimalistic-pac-setter/extension/_locales/en/messages.json new file mode 100644 index 0000000..c9d800a --- /dev/null +++ b/extensions/chromium/minimalistic-pac-setter/extension/_locales/en/messages.json @@ -0,0 +1,17 @@ +{ + "extName": { + "message": "Runet Censorship Bypass" + }, + "extDesc": { + "message": "Circumvent Russian internet censorship:" + }, + "proxy": { + "message": "proxy" + }, + "noControl": { + "message": "Other extension controls proxy!" + }, + "which": { + "message": "Which?" + } +} diff --git a/extensions/chromium/minimalistic-pac-setter/extension/_locales/ru/messages.json b/extensions/chromium/minimalistic-pac-setter/extension/_locales/ru/messages.json new file mode 100644 index 0000000..53784a1 --- /dev/null +++ b/extensions/chromium/minimalistic-pac-setter/extension/_locales/ru/messages.json @@ -0,0 +1,17 @@ +{ + "extName": { + "message": "Обход блокировок Рунета" + }, + "extDesc": { + "message": "Обход интернет-цензуры в России:" + }, + "proxy": { + "message": "прокси" + }, + "noControl": { + "message": "Другое расширение контролирует настройки прокси!" + }, + "which": { + "message": "Какое?" + } +} diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/default-grayscale-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/default-grayscale-128.png new file mode 100644 index 0000000..277056b Binary files /dev/null and b/extensions/chromium/minimalistic-pac-setter/extension/icons/default-grayscale-128.png differ diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/default-mask-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/default-mask-128.png new file mode 100644 index 0000000..2c6db3a Binary files /dev/null and b/extensions/chromium/minimalistic-pac-setter/extension/icons/default-mask-128.png differ diff --git a/extensions/chromium/minimalistic-pac-setter/extension/manifest.json b/extensions/chromium/minimalistic-pac-setter/extension/manifest.json index 208d5b5..44f4b7c 100755 --- a/extensions/chromium/minimalistic-pac-setter/extension/manifest.json +++ b/extensions/chromium/minimalistic-pac-setter/extension/manifest.json @@ -1,9 +1,10 @@ { "manifest_version": 2, - "name": "Обход блокировок Рунета 0.15", - "description": "Аргументы против цензуры: https://git.io/vEkI9", - "version": "0.0.0.15", + "name": "__MSG_extName__", + "default_locale": "en", + "description": "__MSG_extDesc__ https://rebrand.ly/ac-wiki", + "version": "0.0.0.16", "icons": { "128": "/icons/default-128.png" }, @@ -22,7 +23,13 @@ ], "background": { - "scripts": ["00-init-apis.js", "11-api-error-handlers.js", "12-api-sync-pac-script-with-pac-provider.js", "30-block-informer.js", "40-context-menus.js"] + "scripts": [ + "00-init-apis.js", + "11-api-error-handlers.js", + "12-api-sync-pac-script-with-pac-provider.js", + "30-block-informer.js", + "40-context-menus.js" + ] }, "browser_action": { "default_title": "Этот сайт благословлён", diff --git a/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.html b/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.html index 5251c58..11acaa4 100755 --- a/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.html +++ b/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.html @@ -1,8 +1,12 @@  - + Выбор провайдера PAC + + +
+
Обновлялись: ...
-
Загрузка...
+ Загрузка...
Я ❤️ уведомления:
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 index 82f42f4..f197da4 100755 --- 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 @@ -7,17 +7,12 @@ chrome.runtime.getBackgroundPage( (backgroundPage) => const setStatusTo = (msg) => { - const status = getStatus(); - if (msg) { - status.classList.remove('off'); - status.innerHTML = msg; - } else { - status.classList.add('off'); - } + getStatus().innerHTML = msg; }; const antiCensorRu = backgroundPage.apis.antiCensorRu; + const errorHandlers = backgroundPage.apis.errorHandlers; // SET DATE @@ -26,15 +21,14 @@ chrome.runtime.getBackgroundPage( (backgroundPage) => let dateForUser = 'никогда'; if( antiCensorRu.lastPacUpdateStamp ) { let diff = Date.now() - antiCensorRu.lastPacUpdateStamp; - let units = ' мс'; + let units = 'мс'; const gauges = [ - [1000, ' с'], - [60, ' мин'], - [60, ' ч'], - [24, ' дн'], + [1000, 'с'], + [60, 'мин'], + [60, 'ч'], + [24, 'дн'], [7, ' недель'], [4, ' месяцев'], - [12, ' г'], ]; for(const g of gauges) { const diffy = Math.floor(diff / g[0]); @@ -47,7 +41,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) => } const dateElement = document.querySelector('.update-date'); - dateElement.innerText = dateForUser; + dateElement.innerText = dateForUser + ' / T=' + (antiCensorRu.pacUpdatePeriodInMinutes/60) + 'ч'; dateElement.title = new Date(antiCensorRu.lastPacUpdateStamp) .toLocaleString('ru-RU'); @@ -95,7 +89,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) => ); getStatus().querySelector('.link-button').onclick = function() { - backgroundPage.apis.errorHandlers.viewError(err); + errorHandlers.viewError(err); return false; }; @@ -180,7 +174,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) => } const conpanel = document.getElementById('list-of-handlers'); - backgroundPage.apis.errorHandlers.getEventsMap().forEach( (value, name) => { + errorHandlers.getEventsMap().forEach( (value, name) => { const li = document.createElement('li'); li.innerHTML = ` @@ -201,11 +195,22 @@ chrome.runtime.getBackgroundPage( (backgroundPage) => }); + if( errorHandlers.ifNotControlled ) { + console.log('ADDING'); + 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/extension/pages/choose-pac-provider/keep-links-clickable.js b/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/keep-links-clickable.js index 31ce3c5..509abd3 100644 --- a/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/keep-links-clickable.js +++ b/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/keep-links-clickable.js @@ -4,31 +4,35 @@ In popup links are not clickable at all, fix it. On other pages "chrome://" links are not clickable, fix it. Use only if really required because of performance penalty. */ +{ -const target = document.getElementById('status'); + const target = document.documentElement; -const updateLinks = () => { + const updateLinks = () => { - const links = document.querySelectorAll('a:not([href=""])'); - for (let i = 0; i < links.length; i++) { - const ln = links[i]; - const location = ln.href; - ln.onclick = function() { + console.log('UPDATE'); + const links = document.querySelectorAll('a:not([href=""])'); + for (let i = 0; i < links.length; i++) { + const ln = links[i]; + const location = ln.href; + ln.onclick = function() { - chrome.tabs.create({active: !this.dataset.inBg, url: location}); - return false; + chrome.tabs.create({active: !this.dataset.inBg, url: location}); + return false; - }; - } + }; + } -}; + }; -new MutationObserver( updateLinks ) - .observe(target, { - attributes: false, - subtree: true, - childList: true, - characterData: false, - }); + new MutationObserver( updateLinks ) + .observe(target, { + attributes: true, + subtree: true, + childList: true, + characterData: false, + }); -document.addEventListener('DOMContentLoaded', updateLinks); + document.addEventListener('DOMContentLoaded', updateLinks); + +}