mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-24 02:13:43 +03:00
changed name, -bugs: migration & alarms
This commit is contained in:
parent
046dfdbdec
commit
3e89c372b9
|
@ -9,7 +9,7 @@
|
||||||
It pertains not only to page refesh but to newly opened pages too.
|
It pertains not only to page refesh but to newly opened pages too.
|
||||||
Also on loosing title see:
|
Also on loosing title see:
|
||||||
https://github.com/ilyaigpetrov/repository-for-chrome-bugs/blob/master/browserAction-title-lost-after-setting/background.js
|
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 = {};
|
window.onTabUpdated = {};
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 901 B |
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
|
|
||||||
"name": "Ненавязчивый РосКомНадзор NEW",
|
"name": "Обход блокировок Рунета",
|
||||||
"description": "Аргументы против цензуры: https://git.io/vEkI9",
|
"description": "Аргументы против цензуры: https://git.io/vEkI9",
|
||||||
"version": "0.0.0.10",
|
"version": "0.0.0.10",
|
||||||
"icons": {
|
"icons": {
|
||||||
|
|
|
@ -18,10 +18,8 @@ function renderPage() {
|
||||||
status.classList.add('off');
|
status.classList.add('off');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('ABC');
|
|
||||||
chrome.runtime.getBackgroundPage( backgroundPage => {
|
chrome.runtime.getBackgroundPage( backgroundPage => {
|
||||||
|
|
||||||
backgroundPage.console.log('Options page opened.');
|
|
||||||
var antiCensorRu = backgroundPage.antiCensorRu;
|
var antiCensorRu = backgroundPage.antiCensorRu;
|
||||||
|
|
||||||
// SET DATE
|
// SET DATE
|
||||||
|
@ -129,7 +127,7 @@ function renderPage() {
|
||||||
<a href class="ext">chrome://extensions</a> › Это расширение › Отладка страниц: фоновая страница › Console (DevTools)';
|
<a href class="ext">chrome://extensions</a> › Это расширение › Отладка страниц: фоновая страница › Console (DevTools)';
|
||||||
getStatus().replaceChild(div, this);
|
getStatus().replaceChild(div, this);
|
||||||
div.querySelector('.ext').onclick = () => {
|
div.querySelector('.ext').onclick = () => {
|
||||||
chrome.tabs.create({ url: "chrome://extensions" });
|
chrome.tabs.create({ url: 'chrome://extensions?id='+ chrome.runtime.id });
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Task 1. Gets IP for host proxy.antizapret.prostovpn.org with dns-lg.com.
|
Task 1. Gets IPs for proxies of antizapret/anticenz with dns-lg.com.
|
||||||
This IP is used in block-informer to inform user when proxy is ON.
|
These IPs are 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 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 2 hours.
|
Task 3. Schedules tasks 1 & 2 for every 4 hours.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
In background scripts use window.antiCensorRu public variables.
|
In background scripts use window.antiCensorRu public variables.
|
||||||
In pages window.antiCensorRu are not accessible,
|
In pages window.antiCensorRu are not accessible,
|
||||||
|
@ -64,7 +63,6 @@ window.antiCensorRu = {
|
||||||
lastPacUpdateStamp: 0,
|
lastPacUpdateStamp: 0,
|
||||||
|
|
||||||
// PROTECTED
|
// PROTECTED
|
||||||
|
|
||||||
_periodicUpdateAlarmReason: 'Периодичное обновление PAC-скрипта Антизапрет',
|
_periodicUpdateAlarmReason: 'Периодичное обновление PAC-скрипта Антизапрет',
|
||||||
|
|
||||||
pushToStorage(cb) {
|
pushToStorage(cb) {
|
||||||
|
@ -98,6 +96,8 @@ window.antiCensorRu = {
|
||||||
|
|
||||||
syncWithPacProvider(cb) {
|
syncWithPacProvider(cb) {
|
||||||
var cb = cb || (() => {});
|
var cb = cb || (() => {});
|
||||||
|
if (!this.pacProvider)
|
||||||
|
return cb({clarification: 'Сперва выберите PAC-провайдера.'});
|
||||||
|
|
||||||
var pacSetPromise = new Promise(
|
var pacSetPromise = new Promise(
|
||||||
(resolve, reject) => setPacScriptFromProvider(
|
(resolve, reject) => setPacScriptFromProvider(
|
||||||
|
@ -127,6 +127,13 @@ window.antiCensorRu = {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setAlarms() {
|
||||||
|
chrome.alarms.create(
|
||||||
|
this._periodicUpdateAlarmReason,
|
||||||
|
{ periodInMinutes: 4*60 }
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
installPac(key, cb) {
|
installPac(key, cb) {
|
||||||
|
|
||||||
if(typeof(key) === 'function') {
|
if(typeof(key) === 'function') {
|
||||||
|
@ -139,10 +146,7 @@ window.antiCensorRu = {
|
||||||
|
|
||||||
var cb = asyncLogGroup('Installing PAC...', cb);
|
var cb = asyncLogGroup('Installing PAC...', cb);
|
||||||
|
|
||||||
chrome.alarms.create(
|
this.setAlarms();
|
||||||
this._periodicUpdateAlarmReason,
|
|
||||||
{ periodInMinutes: 4*60 }
|
|
||||||
);
|
|
||||||
|
|
||||||
return this.syncWithPacProvider(cb);
|
return this.syncWithPacProvider(cb);
|
||||||
|
|
||||||
|
@ -168,6 +172,8 @@ chrome.storage.local.get(null, oldStorage => {
|
||||||
|
|
||||||
console.log('Init on storage:', oldStorage);
|
console.log('Init on storage:', oldStorage);
|
||||||
|
|
||||||
|
antiCensorRu.ifFirstInstall = Object.keys(oldStorage).length === 0;
|
||||||
|
|
||||||
// Finish each init with this callback setting alarm listeners.
|
// Finish each init with this callback setting alarm listeners.
|
||||||
function cb(err) {
|
function cb(err) {
|
||||||
chrome.alarms.onAlarm.addListener(
|
chrome.alarms.onAlarm.addListener(
|
||||||
|
@ -183,17 +189,19 @@ chrome.storage.local.get(null, oldStorage => {
|
||||||
chrome.alarms.get(
|
chrome.alarms.get(
|
||||||
antiCensorRu._periodicUpdateAlarmReason,
|
antiCensorRu._periodicUpdateAlarmReason,
|
||||||
alarm => {
|
alarm => {
|
||||||
if (!alarm)
|
if (alarm)
|
||||||
return console.error('ALARM NOT SET');
|
|
||||||
console.log(
|
console.log(
|
||||||
'Next update is scheduled on', new Date(alarm.scheduledTime).toLocaleString('ru-RU')
|
'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
|
// INSTALL
|
||||||
antiCensorRu.ifFirstInstall = Object.keys(oldStorage).length === 0;
|
|
||||||
if (antiCensorRu.ifFirstInstall) {
|
if (antiCensorRu.ifFirstInstall) {
|
||||||
console.log('Installing...');
|
console.log('Installing...');
|
||||||
return chrome.runtime.openOptionsPage(cb);
|
return chrome.runtime.openOptionsPage(cb);
|
||||||
|
@ -208,7 +216,7 @@ chrome.storage.local.get(null, oldStorage => {
|
||||||
|
|
||||||
// LAUNCH, RELOAD, UPDATE
|
// LAUNCH, RELOAD, UPDATE
|
||||||
|
|
||||||
antiCensorRu._currentPacProviderKey = oldStorage._currentPacProviderKey || antiCensorRu._currentPacProviderKey;
|
antiCensorRu._currentPacProviderKey = oldStorage._currentPacProviderKey;
|
||||||
antiCensorRu.lastPacUpdateStamp = oldStorage.lastPacUpdateStamp || antiCensorRu.lastPacUpdateStamp;
|
antiCensorRu.lastPacUpdateStamp = oldStorage.lastPacUpdateStamp || antiCensorRu.lastPacUpdateStamp;
|
||||||
|
|
||||||
if (antiCensorRu.version === oldStorage.version) {
|
if (antiCensorRu.version === oldStorage.version) {
|
||||||
|
@ -219,7 +227,8 @@ chrome.storage.local.get(null, oldStorage => {
|
||||||
|
|
||||||
// UPDATE & MIGRATION
|
// UPDATE & MIGRATION
|
||||||
console.log('Updating...');
|
console.log('Updating...');
|
||||||
return updatePacProxyIps(
|
return antiCensorRu.pacProvider &&
|
||||||
|
updatePacProxyIps(
|
||||||
antiCensorRu.pacProvider,
|
antiCensorRu.pacProvider,
|
||||||
ipsError => {
|
ipsError => {
|
||||||
if (ipsError) ipsError.ifNotCritical = true;
|
if (ipsError) ipsError.ifNotCritical = true;
|
||||||
|
@ -281,10 +290,6 @@ function httpGet(url, cb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePacProxyIps(provider, 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 cb = asyncLogGroup('Getting IP for '+ provider.proxyHosts.join(', ') +'...', cb);
|
||||||
var failure = {
|
var failure = {
|
||||||
clarification: {message:'Не удалось получить один или несколько IP адресов для прокси-серверов. Иконка для уведомления об обходе блокировок может не отображаться.'},
|
clarification: {message:'Не удалось получить один или несколько IP адресов для прокси-серверов. Иконка для уведомления об обходе блокировок может не отображаться.'},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user