mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-24 02:13:43 +03:00
Add Google DNS, change context menu, change code style, prepare 0.0.0.14 release images and text
This commit is contained in:
parent
92582629d5
commit
f3ffda676e
|
@ -1,6 +1,6 @@
|
||||||
# О расширении
|
# О расширении
|
||||||
|
|
||||||
Обход Интернет-цензуры в России пока что не является преступлением.
|
Обход интернет-цензуры в России пока что не является преступлением.
|
||||||
|
|
||||||
Расширение позволяет обходить блокировки РосКомНадзора, давая вам доступ
|
Расширение позволяет обходить блокировки РосКомНадзора, давая вам доступ
|
||||||
к библиотекам, энциклопедиям, сайтам оппозиционеров, а также к неповинным
|
к библиотекам, энциклопедиям, сайтам оппозиционеров, а также к неповинным
|
||||||
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
Если расширение не работает: https://git.io/vgDDj
|
Если расширение не работает: https://git.io/vgDDj
|
||||||
|
|
||||||
|
Антицензура на Реддите: https://www.reddit.com/r/anticensorship_russia
|
||||||
|
Группа в G+: https://goo.gl/Lh0Cjh
|
||||||
История изменений: https://github.com/ilyaigpetrov/anti-censorship-russia/releases
|
История изменений: https://github.com/ilyaigpetrov/anti-censorship-russia/releases
|
||||||
|
|
||||||
# Дополнительно
|
# Дополнительно
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 59 KiB |
|
@ -9,15 +9,13 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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 is not accessible,
|
||||||
use chrome.runtime.getBackgroundPage(..),
|
use chrome.runtime.getBackgroundPage(..),
|
||||||
extension.getBackgroundPage is deprecated
|
extension.getBackgroundPage is deprecated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window.antiCensorRu = {
|
window.antiCensorRu = {
|
||||||
|
|
||||||
// PUBLIC
|
|
||||||
|
|
||||||
version: chrome.runtime.getManifest().version,
|
version: chrome.runtime.getManifest().version,
|
||||||
|
|
||||||
pacProviders: {
|
pacProviders: {
|
||||||
|
@ -25,8 +23,8 @@ window.antiCensorRu = {
|
||||||
pacUrl: 'https://antizapret.prostovpn.org/proxy.pac',
|
pacUrl: 'https://antizapret.prostovpn.org/proxy.pac',
|
||||||
proxyHosts: ['proxy.antizapret.prostovpn.org'],
|
proxyHosts: ['proxy.antizapret.prostovpn.org'],
|
||||||
proxyIps: {
|
proxyIps: {
|
||||||
'195.154.110.37': 'proxy.antizapret.prostovpn.org',
|
'195.123.209.38': 'proxy.antizapret.prostovpn.org',
|
||||||
'195.123.209.38': 'proxy.antizapret.prostovpn.org'
|
'2a02:27ac::10': 'proxy.antizapret.prostovpn.org'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Антиценз: {
|
Антиценз: {
|
||||||
|
@ -41,8 +39,8 @@ window.antiCensorRu = {
|
||||||
//pacUrl: 'https://drive.google.com/uc?export=download&id=0B-ZCVSvuNWf0WGczNmJzY3gzMWc', // Beta
|
//pacUrl: 'https://drive.google.com/uc?export=download&id=0B-ZCVSvuNWf0WGczNmJzY3gzMWc', // Beta
|
||||||
proxyHosts: ['proxy.antizapret.prostovpn.org', 'gw2.anticenz.org'],
|
proxyHosts: ['proxy.antizapret.prostovpn.org', 'gw2.anticenz.org'],
|
||||||
proxyIps: {
|
proxyIps: {
|
||||||
'195.154.110.37': 'proxy.antizapret.prostovpn.org',
|
|
||||||
'195.123.209.38': 'proxy.antizapret.prostovpn.org',
|
'195.123.209.38': 'proxy.antizapret.prostovpn.org',
|
||||||
|
'2a02:27ac::10': 'proxy.antizapret.prostovpn.org',
|
||||||
'5.196.220.114': 'gw2.anticenz.org'
|
'5.196.220.114': 'gw2.anticenz.org'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +50,7 @@ window.antiCensorRu = {
|
||||||
|
|
||||||
get currentPacProviderKey() { return this._currentPacProviderKey },
|
get currentPacProviderKey() { return this._currentPacProviderKey },
|
||||||
set currentPacProviderKey(newKey) {
|
set currentPacProviderKey(newKey) {
|
||||||
|
|
||||||
if (newKey && !this.pacProviders[newKey])
|
if (newKey && !this.pacProviders[newKey])
|
||||||
throw new IllegalArgumentException('No provider for key:' + newKey);
|
throw new IllegalArgumentException('No provider for key:' + newKey);
|
||||||
this._currentPacProviderKey = newKey;
|
this._currentPacProviderKey = newKey;
|
||||||
|
@ -65,17 +64,19 @@ window.antiCensorRu = {
|
||||||
ifFirstInstall: false,
|
ifFirstInstall: false,
|
||||||
lastPacUpdateStamp: 0,
|
lastPacUpdateStamp: 0,
|
||||||
|
|
||||||
// PROTECTED
|
|
||||||
_periodicUpdateAlarmReason: 'Периодичное обновление PAC-скрипта Антизапрет',
|
_periodicUpdateAlarmReason: 'Периодичное обновление PAC-скрипта Антизапрет',
|
||||||
|
|
||||||
pushToStorage(cb) {
|
pushToStorage(cb) {
|
||||||
console.log('Pushing...');
|
|
||||||
|
|
||||||
// Copy only settable properties.
|
console.log('Pushing to storage...');
|
||||||
var onlySettable = {};
|
|
||||||
for(var key of Object.keys(this))
|
// Copy only settable properties (except functions).
|
||||||
if (Object.getOwnPropertyDescriptor(this, key).writable && typeof(this[key]) !== 'function')
|
const onlySettable = {};
|
||||||
onlySettable[key] = this[key]
|
for(const key of Object.keys(this)) {
|
||||||
|
if (Object.getOwnPropertyDescriptor(this, key).writable && typeof(this[key]) !== 'function') {
|
||||||
|
onlySettable[key] = this[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return chrome.storage.local.clear(
|
return chrome.storage.local.clear(
|
||||||
() => chrome.storage.local.set(
|
() => chrome.storage.local.set(
|
||||||
|
@ -87,28 +88,35 @@ window.antiCensorRu = {
|
||||||
},
|
},
|
||||||
|
|
||||||
pullFromStorage(cb) {
|
pullFromStorage(cb) {
|
||||||
chrome.storage.local.get(null, storage => {
|
|
||||||
console.log('In storage:', storage);
|
chrome.storage.local.get(null, (storage) => {
|
||||||
for(var key of Object.keys(storage))
|
console.log('Pulled from storage:', storage);
|
||||||
|
for(const key of Object.keys(storage)) {
|
||||||
this[key] = storage[key];
|
this[key] = storage[key];
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Synced with storage, any callback?', !!cb);
|
console.log('Synced with storage, any callback?', !!cb);
|
||||||
if (cb)
|
if (cb) {
|
||||||
cb(chrome.runtime.lastError, storage);
|
cb(chrome.runtime.lastError, storage);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
syncWithPacProvider(cb) {
|
syncWithPacProvider(cb) {
|
||||||
var cb = asyncLogGroup('Syncing with PAC provider...', cb);
|
|
||||||
if (!this.pacProvider)
|
cb = asyncLogGroup('Syncing with PAC provider...', cb);
|
||||||
|
if (!this.pacProvider) {
|
||||||
return cb({clarification:{message:'Сперва выберите PAC-провайдера.'}});
|
return cb({clarification:{message:'Сперва выберите PAC-провайдера.'}});
|
||||||
|
}
|
||||||
|
|
||||||
var pacSetPromise = new Promise(
|
var pacSetPromise = new Promise(
|
||||||
(resolve, reject) => setPacScriptFromProvider(
|
(resolve, reject) => setPacScriptFromProvider(
|
||||||
this.pacProvider,
|
this.pacProvider,
|
||||||
(err, res) => {
|
(err, res) => {
|
||||||
if (err)
|
|
||||||
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
this.lastPacUpdateStamp = Date.now();
|
this.lastPacUpdateStamp = Date.now();
|
||||||
this.ifFirstInstall = false;
|
this.ifFirstInstall = false;
|
||||||
|
@ -121,14 +129,16 @@ window.antiCensorRu = {
|
||||||
|
|
||||||
return updatePacProxyIps(
|
return updatePacProxyIps(
|
||||||
this.pacProvider,
|
this.pacProvider,
|
||||||
ipsError => {
|
(ipsError) => {
|
||||||
if (ipsError && ipsError.clarification)
|
|
||||||
|
if (ipsError && ipsError.clarification) {
|
||||||
ipsError.clarification.ifNotCritical = true;
|
ipsError.clarification.ifNotCritical = true;
|
||||||
|
}
|
||||||
pacSetPromise.then(
|
pacSetPromise.then(
|
||||||
res => this.pushToStorage(
|
(res) => this.pushToStorage(
|
||||||
pushError => pushError ? cb(pushError) : cb(ipsError, res)
|
(pushError) => pushError ? cb(pushError) : cb(ipsError, res)
|
||||||
),
|
),
|
||||||
err => cb(err)
|
cb
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -138,8 +148,8 @@ window.antiCensorRu = {
|
||||||
|
|
||||||
setAlarms() {
|
setAlarms() {
|
||||||
|
|
||||||
var nextUpdateMoment = this.lastPacUpdateStamp + this._pacUpdatePeriodInMinutes*60*1000;
|
let nextUpdateMoment = this.lastPacUpdateStamp + this._pacUpdatePeriodInMinutes*60*1000;
|
||||||
var now = Date.now();
|
const now = Date.now();
|
||||||
if (nextUpdateMoment < now)
|
if (nextUpdateMoment < now)
|
||||||
nextUpdateMoment = now;
|
nextUpdateMoment = now;
|
||||||
|
|
||||||
|
@ -157,23 +167,27 @@ window.antiCensorRu = {
|
||||||
},
|
},
|
||||||
|
|
||||||
installPac(key, cb) {
|
installPac(key, cb) {
|
||||||
|
|
||||||
if(typeof(key) === 'function') {
|
if(typeof(key) === 'function') {
|
||||||
cb = key;
|
cb = key;
|
||||||
key = undefined;
|
key = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(key)
|
if(key) {
|
||||||
this.currentPacProviderKey = key;
|
this.currentPacProviderKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
return this.syncWithPacProvider(cb);
|
return this.syncWithPacProvider(cb);
|
||||||
},
|
},
|
||||||
|
|
||||||
clearPac(cb) {
|
clearPac(cb) {
|
||||||
var cb = asyncLogGroup('Cearing alarms and PAC...', cb);
|
|
||||||
|
cb = asyncLogGroup('Cearing alarms and PAC...', cb);
|
||||||
chrome.alarms.clearAll(
|
chrome.alarms.clearAll(
|
||||||
() => chrome.proxy.settings.clear(
|
() => chrome.proxy.settings.clear(
|
||||||
{},
|
{},
|
||||||
() => {
|
() => {
|
||||||
|
|
||||||
this.currentPacProviderKey = undefined;
|
this.currentPacProviderKey = undefined;
|
||||||
return this.pushToStorage(cb);
|
return this.pushToStorage(cb);
|
||||||
}
|
}
|
||||||
|
@ -184,7 +198,7 @@ window.antiCensorRu = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// ON EACH LAUNCH, STARTUP, RELOAD, UPDATE, ENABLE
|
// ON EACH LAUNCH, STARTUP, RELOAD, UPDATE, ENABLE
|
||||||
chrome.storage.local.get(null, oldStorage => {
|
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;
|
antiCensorRu.ifFirstInstall = Object.keys(oldStorage).length === 0;
|
||||||
|
@ -197,10 +211,11 @@ chrome.storage.local.get(null, oldStorage => {
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.alarms.onAlarm.addListener(
|
chrome.alarms.onAlarm.addListener(
|
||||||
alarm => {
|
(alarm) => {
|
||||||
|
|
||||||
if (alarm.name === antiCensorRu._periodicUpdateAlarmReason) {
|
if (alarm.name === antiCensorRu._periodicUpdateAlarmReason) {
|
||||||
console.log('Periodic PAC update triggered:', new Date().toLocaleString('ru-RU'));
|
console.log('Periodic PAC update triggered:', new Date().toLocaleString('ru-RU'));
|
||||||
antiCensorRu.syncWithPacProvider();
|
antiCensorRu.syncWithPacProvider(/* Swallows errors. */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -212,8 +227,9 @@ chrome.storage.local.get(null, oldStorage => {
|
||||||
return chrome.runtime.openOptionsPage();
|
return chrome.runtime.openOptionsPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!antiCensorRu.pacProvider)
|
if (!antiCensorRu.pacProvider) {
|
||||||
return console.log('No PAC provider set. Do nothing.');
|
return console.log('No PAC provider set. Do nothing.');
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
1. There is no way to check that chrome.runtime.onInstalled wasn't fired except timeout.
|
1. There is no way to check that chrome.runtime.onInstalled wasn't fired except timeout.
|
||||||
|
@ -222,7 +238,7 @@ chrome.storage.local.get(null, oldStorage => {
|
||||||
Better on each launch then on each pull.
|
Better on each launch then on each pull.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var ifAlarmTriggered = antiCensorRu.setAlarms();
|
const ifAlarmTriggered = antiCensorRu.setAlarms();
|
||||||
|
|
||||||
if (antiCensorRu.version === oldStorage.version) {
|
if (antiCensorRu.version === oldStorage.version) {
|
||||||
// LAUNCH, RELOAD, ENABLE
|
// LAUNCH, RELOAD, ENABLE
|
||||||
|
@ -232,11 +248,12 @@ chrome.storage.local.get(null, oldStorage => {
|
||||||
|
|
||||||
// UPDATE & MIGRATION
|
// UPDATE & MIGRATION
|
||||||
console.log('Extension updated.');
|
console.log('Extension updated.');
|
||||||
if (!ifAlarmTriggered)
|
if (!ifAlarmTriggered) {
|
||||||
updatePacProxyIps(
|
updatePacProxyIps(
|
||||||
antiCensorRu.pacProvider,
|
antiCensorRu.pacProvider,
|
||||||
ipsError => ipsError ? console.error('Error updating IPs:', ipsError) : antiCensorRu.pushToStorage()
|
(ipsError) => ipsError ? console.error('Error updating IPs:', ipsError) : antiCensorRu.pushToStorage(/* Swallows errors. */)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
@ -257,81 +274,110 @@ chrome.storage.local.get(null, oldStorage => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function asyncLogGroup() {
|
function asyncLogGroup() {
|
||||||
var args = [].slice.apply(arguments);
|
|
||||||
var cb = args.pop();
|
const args = [].slice.apply(arguments);
|
||||||
|
const cb = args.pop() || (() => {});
|
||||||
console.group.apply(console, args);
|
console.group.apply(console, args);
|
||||||
return function() {
|
return function() {
|
||||||
|
|
||||||
console.groupEnd();
|
console.groupEnd();
|
||||||
console.log('Group finished.');
|
console.log('Group finished.');
|
||||||
var _cb = cb || (() => {});
|
return cb.apply(this, arguments);
|
||||||
return _cb.apply(this, arguments);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function httpGet(url, cb) {
|
function httpGet(url, cb) {
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
return fetch(url).then(
|
return fetch(url).then(
|
||||||
res => {
|
(res) => {
|
||||||
var textCb = err => cb && res.text().then( text => cb(err, text), cb );
|
|
||||||
var status = res.status;
|
const textCb = (err) => cb && res.text().then( text => cb(err, text), cb );
|
||||||
|
const status = res.status;
|
||||||
if ( !( status >= 200 && status < 300 || status === 304 ) ) {
|
if ( !( status >= 200 && status < 300 || status === 304 ) ) {
|
||||||
res.clarification = {message: 'Получен ответ с неудачным HTTP-кодом '+status+'.'};
|
res.clarification = {message: 'Получен ответ с неудачным HTTP-кодом ' + status + '.'};
|
||||||
return textCb(res);
|
return textCb(res);
|
||||||
}
|
}
|
||||||
console.log('GETed with success.');
|
console.log('GETed with success:', url, Date.now() - start);
|
||||||
return textCb();
|
return textCb();
|
||||||
},
|
},
|
||||||
err => {
|
(err) => {
|
||||||
|
|
||||||
err.clarification = {message: 'Что-то не так с сетью, проверьте соединение.'};
|
err.clarification = {message: 'Что-то не так с сетью, проверьте соединение.'};
|
||||||
return cb && cb(err);
|
return cb && cb(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getIpsAndCnames(host, cb) {
|
function getOneDnsRecord(args, cb) {
|
||||||
/*
|
|
||||||
Answer format:
|
// args: { host:..., type: 'AAAA', filter: ['AAAA'] }
|
||||||
"answer":
|
if (!(args.host && args.type && cb)) {
|
||||||
[
|
throw new Error('Wrong args:' + host + ',' + type);
|
||||||
{
|
|
||||||
"name": "proxy.antizapret.prostovpn.org.",
|
|
||||||
"type": "A",
|
|
||||||
"class": "IN",
|
|
||||||
"ttl": 409,
|
|
||||||
"rdlength": 4,
|
|
||||||
"rdata": "195.123.209.38"
|
|
||||||
}
|
}
|
||||||
...
|
|
||||||
CNAME example: ghs.google.com
|
const type2str = {
|
||||||
**/
|
// https://en.wikipedia.org/wiki/List_of_DNS_record_types
|
||||||
|
// A, AAAA may be localized (github, e.g.), but you may use ANY
|
||||||
|
1: 'A', // IPv4
|
||||||
|
28: 'AAAA', // IPv6
|
||||||
|
2: 'NS',
|
||||||
|
5: 'CNAME', // Synonyms, returned by server together with A/AAAA.
|
||||||
|
255: 'ANY' // Deprecated on some servers, not recommended
|
||||||
|
};
|
||||||
|
|
||||||
httpGet(
|
httpGet(
|
||||||
'http://www.dns-lg.com/google1/'+ host +'/a',
|
'https://dns.google.com/resolve?type=' + args.type + '&name=' + args.host,
|
||||||
(err, res) => {
|
(err, res) => {
|
||||||
if (res)
|
if (res) {
|
||||||
try {
|
try {
|
||||||
res = JSON.parse(res);
|
res = JSON.parse(res);
|
||||||
if (err)
|
console.log('Json parsed.');
|
||||||
err.clarification.message += ' Сервер: '+ res.message;
|
if (err || res.Status) {
|
||||||
|
const msg = ['Answer', 'Comment', 'Status']
|
||||||
|
.filter( (prop) => res[ prop ] )
|
||||||
|
.map( (prop) => prop + ': ' + JSON.stringify( res[ prop ] ) )
|
||||||
|
.join(', \n');
|
||||||
|
err.clarification.message += ' Сервер (json): ' + msg;
|
||||||
|
err.data = err.data || res;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
res = res.answer;
|
res = res.Answer || [];
|
||||||
for (const r of res) {
|
for (const record of res) {
|
||||||
r.data = r.rdata;
|
record.type = type2str[ record.type ];
|
||||||
delete r.rdata;
|
}
|
||||||
|
if ( args.filter ) {
|
||||||
|
res = res.filter( (record) => args.filter.indexOf( record.type ) > -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(e) {
|
}
|
||||||
err = err || {clarification:{message:''}};
|
catch(e) {
|
||||||
err.clarification.message += ' Сервер: '+ res;
|
err = e || err || {clarification:{message:''}};
|
||||||
|
err.clarification = err.clarification || { message: '' };
|
||||||
|
err.clarification.message += ' Сервер (текст): '+ res;
|
||||||
err.clarification.message.trim();
|
err.clarification.message.trim();
|
||||||
|
err.data = err.data || res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cb( err, res );
|
return cb( err, res );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
function getIpsAndCnames(host, cb) {
|
function getDnsRecords(args, cb) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Answer format:
|
Example of input:
|
||||||
|
{
|
||||||
|
// Required
|
||||||
|
host: 'proxy.navalny.cia.gov',
|
||||||
|
// Optional
|
||||||
|
types: {
|
||||||
|
string: ['A', 'AAAA'], // <- Default. Makes one request per each type.
|
||||||
|
filter: ['A', 'AAAA'], // <- Default. E.g., you want to get rid of CNAME type from response.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Exmple of answer from google:
|
||||||
"Answer":
|
"Answer":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -341,67 +387,50 @@ function getIpsAndCnames(host, cb) {
|
||||||
"data": "17.178.96.59" // Data for A - IP address as text
|
"data": "17.178.96.59" // Data for A - IP address as text
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
|
Exmple of output:
|
||||||
|
The same as google, but types _may be_ canonical strings ('AAAA', 'A')
|
||||||
**/
|
**/
|
||||||
|
|
||||||
const type2str = {
|
if ( !args.host.length ) {
|
||||||
// https://en.wikipedia.org/wiki/List_of_DNS_record_types
|
throw new Error('args.host is required: ' + args.host);
|
||||||
1: 'A',
|
}
|
||||||
2: 'NS',
|
args.types = Object.assign({
|
||||||
28: 'AAAA',
|
string: ['A', 'AAAA'],
|
||||||
5: 'CNAME'
|
filter: ['A', 'AAAA']
|
||||||
};
|
}, args.types);
|
||||||
|
|
||||||
httpGet(
|
const promises = args.types.string.map(
|
||||||
'https://dns.google.com/resolve?type=A&name=' + host
|
(type) => new Promise( (resolve, reject) =>
|
||||||
(err, res) => {
|
getOneDnsRecord({ host: args.host, type: type, filter: args.types.filter }, (err, res) => err ? reject(err) : resolve(res) )
|
||||||
if (res) {
|
)
|
||||||
try {
|
|
||||||
res = JSON.parse(res);
|
|
||||||
if (err || res.Status) {
|
|
||||||
const msg = ['Answer', 'Comment', 'Status']
|
|
||||||
.filter( (prop) => res[ prop ] )
|
|
||||||
.map( (prop) => prop + ': ' + JSON.stringify( res[ prop ] ) )
|
|
||||||
.join(', \n');
|
|
||||||
err.clarification.message += ' Сервер: '+ msg;
|
|
||||||
err.data = err.data || res;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
res = res.Answer;
|
|
||||||
for (const r of res) {
|
|
||||||
r.type = type2str[ r.type ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(e) {
|
|
||||||
err = err || {clarification:{message:''}};
|
|
||||||
err.clarification.message += ' Сервер: '+ res;
|
|
||||||
err.clarification.message.trim();
|
|
||||||
err.data = err.data || res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cb( err, res );
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
Promise.all(promises).then( (answers) => cb( null, [].concat.apply([], answers) ), cb );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getIpDnsRecords = (host, cb) => getDnsRecords({ host: host }, cb);
|
||||||
|
|
||||||
function updatePacProxyIps(provider, cb) {
|
function updatePacProxyIps(provider, cb) {
|
||||||
var cb = asyncLogGroup('Getting IP for '+ provider.proxyHosts.join(', ') +'...', cb);
|
|
||||||
var failure = {
|
cb = asyncLogGroup('Getting IP for '+ provider.proxyHosts.join(', ') +'...', cb);
|
||||||
|
let failure = {
|
||||||
clarification: {message:'Не удалось получить один или несколько IP адресов для прокси-серверов. Иконка для уведомления об обходе блокировок может не отображаться.'},
|
clarification: {message:'Не удалось получить один или несколько IP адресов для прокси-серверов. Иконка для уведомления об обходе блокировок может не отображаться.'},
|
||||||
errors: {}
|
errors: {}
|
||||||
};
|
};
|
||||||
var i = 0;
|
let i = 0;
|
||||||
provider.proxyHosts.map(
|
provider.proxyHosts.map(
|
||||||
proxyHost => getIpsAndCnames(
|
(proxyHost) => getIpDnsRecords(
|
||||||
proxyHost,
|
proxyHost,
|
||||||
(err, ans) => {
|
(err, records) => {
|
||||||
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
provider.proxyIps = provider.proxyIps || {};
|
provider.proxyIps = provider.proxyIps || {};
|
||||||
ans.filter( ans => ans.type === 'A' ).map( ans => provider.proxyIps[ ans.data ] = proxyHost );
|
records.forEach( (ans) => provider.proxyIps[ ans.data ] = proxyHost );
|
||||||
} else
|
}
|
||||||
|
else {
|
||||||
failure.errors[proxyHost] = err;
|
failure.errors[proxyHost] = err;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ++i == provider.proxyHosts.length ) {
|
if ( ++i === provider.proxyHosts.length ) {
|
||||||
failure = Object.keys(failure.errors).length ? failure : null;
|
failure = Object.keys(failure.errors).length ? failure : null;
|
||||||
return cb(failure, provider.proxyIps);
|
return cb(failure, provider.proxyIps);
|
||||||
}
|
}
|
||||||
|
@ -411,11 +440,13 @@ function updatePacProxyIps(provider, cb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPacScriptFromProvider(provider, cb) {
|
function setPacScriptFromProvider(provider, cb) {
|
||||||
var cb = asyncLogGroup('Getting pac script from provider...', provider.pacUrl, cb);
|
|
||||||
|
cb = asyncLogGroup('Getting pac script from provider...', provider.pacUrl, cb);
|
||||||
|
|
||||||
httpGet(
|
httpGet(
|
||||||
provider.pacUrl,
|
provider.pacUrl,
|
||||||
(err, res) => {
|
(err, res) => {
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
err.clarification = {
|
err.clarification = {
|
||||||
message: 'Не удалось скачать PAC-скрипт с адреса: '+ provider.pacUrl +'.',
|
message: 'Не удалось скачать PAC-скрипт с адреса: '+ provider.pacUrl +'.',
|
||||||
|
@ -425,7 +456,8 @@ function setPacScriptFromProvider(provider, cb) {
|
||||||
}
|
}
|
||||||
console.log('Clearing chrome proxy settings...');
|
console.log('Clearing chrome proxy settings...');
|
||||||
return chrome.proxy.settings.clear({}, () => {
|
return chrome.proxy.settings.clear({}, () => {
|
||||||
var config = {
|
|
||||||
|
const config = {
|
||||||
mode: 'pac_script',
|
mode: 'pac_script',
|
||||||
pacScript: {
|
pacScript: {
|
||||||
mandatory: false,
|
mandatory: false,
|
||||||
|
|
|
@ -9,33 +9,53 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const removeProtocol = (url) => {
|
const removeProtocol = (url) => {
|
||||||
|
|
||||||
const link = createLink(url);
|
const link = createLink(url);
|
||||||
return link.href.replace( link.protocol + '//', '' );
|
return link.href.replace( link.protocol + '//', '' );
|
||||||
};
|
};
|
||||||
|
|
||||||
createMenuLinkEntry( 'Сайт доступен из-за границы? Is up?', tab => 'http://isup.me/'+ createLink(tab.url).hostname );
|
createMenuLinkEntry( 'Сайт доступен из-за границы? Is up?', (tab) => 'http://isup.me/'+ createLink(tab.url).hostname );
|
||||||
|
|
||||||
window.reestrUrl = 'http://reestr.rublacklist.net/search/?q=';
|
window.reestrUrl = 'http://reestr.rublacklist.net/search/?q=';
|
||||||
|
|
||||||
createMenuLinkEntry( 'Сайт в реестре блокировок?', tab => {
|
createMenuLinkEntry( 'Сайт в реестре блокировок?', (tab) => {
|
||||||
const ifIp = confirm('Да = искать по IP.\nНет = искать по домену.');
|
|
||||||
|
const ifHost = confirm('Да — искать по домену\nНет — искать по IP (зависит от местоположения)');
|
||||||
const hostname = createLink( tab.url ).hostname;
|
const hostname = createLink( tab.url ).hostname;
|
||||||
if (ifIp) {
|
if (ifHost) {
|
||||||
var ip = window.tabWithError2ip[tab.id];
|
return reestrUrl + hostname;
|
||||||
if ( /^[.\d]+$/.test(hostname) || /^[:\dA-Fa-f]+$/.test(hostname) )
|
}
|
||||||
|
let ip = window.tabWithError2ip[tab.id];
|
||||||
|
if ( /^[.\d]+$/.test(hostname) || /^[:\dA-Fa-f]+$/.test(hostname) ) {
|
||||||
ip = hostname;
|
ip = hostname;
|
||||||
|
}
|
||||||
return ip
|
return ip
|
||||||
? reestrUrl + ip
|
? reestrUrl + ip
|
||||||
: chrome.extension.getURL('./pages/is-ip-blocked/index.html') +'?'+ hostname
|
: chrome.extension.getURL('./pages/is-ip-blocked/index.html') +'?'+ hostname
|
||||||
}
|
|
||||||
return reestrUrl + hostname
|
|
||||||
});
|
});
|
||||||
|
|
||||||
createMenuLinkEntry( 'Из кэша Google', tab => 'https://webcache.googleusercontent.com/search?q=cache:' + removeProtocol(tab.url) );
|
createMenuLinkEntry( 'Из кэша Google', (tab) => 'https://webcache.googleusercontent.com/search?q=cache:' + removeProtocol(tab.url) );
|
||||||
|
|
||||||
createMenuLinkEntry( 'Из архива archive.org', tab => 'https://web.archive.org/web/*/' + removeProtocol(tab.url) );
|
createMenuLinkEntry( 'Из архива archive.org', (tab) => 'https://web.archive.org/web/*/' + removeProtocol(tab.url) );
|
||||||
|
|
||||||
createMenuLinkEntry( 'Свежий снимок страницы, Screenshot machine', tab => `
|
createMenuLinkEntry( 'Открыть веб прокси (не наш)', (tab) => 'https://kproxy.com' );
|
||||||
|
|
||||||
|
createMenuLinkEntry( 'Другие варианты', (tab) => {
|
||||||
|
|
||||||
|
const ifPage = confirm('Да — открыть страницу с решениями\nНет — сделать свежий снимок страницы (Screenshot Machine)');
|
||||||
|
return ifPage
|
||||||
|
? chrome.extension.getURL('./pages/other-unblocks/index.html') + '?' + removeProtocol(tab.url)
|
||||||
|
: `data:text/html;charset=utf8,<title>Screenshot machine</title>
|
||||||
|
<form method="POST" action="https://screenshotmachine.com/processor.php">
|
||||||
|
<input name="urlparam" value="${ removeProtocol(tab.url) }" type="hidden">
|
||||||
|
<input name="size" value="F" type="hidden">
|
||||||
|
<input name="cacheLimit" value="0" type="hidden">
|
||||||
|
</form>
|
||||||
|
<script>document.forms[0].submit()</script>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
createMenuLinkEntry( 'Свежий снимок страницы, Screenshot machine', (tab) => `
|
||||||
data:text/html;charset=utf8,<title>Screenshot machine</title>
|
data:text/html;charset=utf8,<title>Screenshot machine</title>
|
||||||
<form method="POST" action="https://screenshotmachine.com/processor.php">
|
<form method="POST" action="https://screenshotmachine.com/processor.php">
|
||||||
<input name="urlparam" value="${ removeProtocol(tab.url) }" type="hidden">
|
<input name="urlparam" value="${ removeProtocol(tab.url) }" type="hidden">
|
||||||
|
@ -44,7 +64,6 @@
|
||||||
</form>
|
</form>
|
||||||
<script>document.forms[0].submit()</script>`
|
<script>document.forms[0].submit()</script>`
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
createMenuLinkEntry( 'Разблокировать страницу по-другому', tab => chrome.extension.getURL('./pages/other-unblocks/index.html') +'?'+ removeProtocol(tab.url) );
|
|
||||||
|
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -95,7 +95,7 @@ chrome.runtime.getBackgroundPage( backgroundPage => {
|
||||||
|
|
||||||
enableDisableInputs();
|
enableDisableInputs();
|
||||||
setStatusTo('Установка...');
|
setStatusTo('Установка...');
|
||||||
antiCensorRu.installPac(pacKey, err => {
|
antiCensorRu.installPac(pacKey, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
var ifNotCritical = err.clarification && err.clarification.ifNotCritical;
|
var ifNotCritical = err.clarification && err.clarification.ifNotCritical;
|
||||||
|
|
||||||
|
@ -114,9 +114,12 @@ chrome.runtime.getBackgroundPage( backgroundPage => {
|
||||||
);
|
);
|
||||||
getStatus().querySelector('.link-button').onclick = function() {
|
getStatus().querySelector('.link-button').onclick = function() {
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
div.innerHTML = '\
|
div.innerHTML = `
|
||||||
Более подробную информацию можно узнать из логов фоновой страницы:<br/>\
|
Более подробную информацию можно узнать из логов фоновой страницы:<br/>
|
||||||
<a href class="ext">chrome://extensions</a> › Это расширение › Отладка страниц: фоновая страница › Console (DevTools)';
|
<a href class="ext">chrome://extensions</a> › Это расширение › Отладка страниц: фоновая страница › Console (DevTools)
|
||||||
|
<br>
|
||||||
|
Ещё: ${JSON.stringify({err: err, stack: err.stack})}
|
||||||
|
`;
|
||||||
getStatus().replaceChild(div, this);
|
getStatus().replaceChild(div, this);
|
||||||
div.querySelector('.ext').onclick = () => {
|
div.querySelector('.ext').onclick = () => {
|
||||||
chrome.tabs.create({ url: 'chrome://extensions?id='+ chrome.runtime.id });
|
chrome.tabs.create({ url: 'chrome://extensions?id='+ chrome.runtime.id });
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
chrome.runtime.getBackgroundPage( backgroundPage => {
|
chrome.runtime.getBackgroundPage( (backgroundPage) => {
|
||||||
|
|
||||||
var hostname = window.location.search.substring(1);
|
const hostname = window.location.search.substring(1);
|
||||||
|
|
||||||
backgroundPage.getIpsAndCnames( hostname, (err, records) =>
|
backgroundPage.getOneDnsRecord( { host: hostname, type: 'A' }, (err, records) =>
|
||||||
err
|
err
|
||||||
? document.write(
|
? document.write(
|
||||||
`<title>IP уже нет</title>
|
`<title>IP уже нет</title>
|
||||||
|
@ -15,7 +15,7 @@ chrome.runtime.getBackgroundPage( backgroundPage => {
|
||||||
? window.location.replace( backgroundPage.reestrUrl + records[0].data )
|
? window.location.replace( backgroundPage.reestrUrl + records[0].data )
|
||||||
: document.write(
|
: document.write(
|
||||||
'<title>Выбор IP</title>'
|
'<title>Выбор IP</title>'
|
||||||
+ '<h4>У домена несколько IP / синонимов:</h4>'
|
+ '<h4>У домена несколько IP / синонимов. Для вашего местоположения:</h4>'
|
||||||
+ records
|
+ records
|
||||||
.sort( (a,b) => a.data.localeCompare(b.data) )
|
.sort( (a,b) => a.data.localeCompare(b.data) )
|
||||||
.map( ans => ans.data.link( ans.type === 'A' ? backgroundPage.reestrUrl + ans.data : window.location.pathname +'?'+ ans.data ) )
|
.map( ans => ans.data.link( ans.type === 'A' ? backgroundPage.reestrUrl + ans.data : window.location.pathname +'?'+ ans.data ) )
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var url = decodeURIComponent(window.location.search.substring(1));
|
const url = decodeURIComponent(window.location.search.substring(1));
|
||||||
document.body.innerHTML = `
|
document.body.innerHTML = `
|
||||||
<input type="text" value="${url}" autofocus style="width: 100%; border: 0; outline: none; font-size: 2em"/>
|
<input type="text" value="${url}" autofocus style="width: 100%; border: 0; outline: none; font-size: 2em"/>
|
||||||
<button>Копировать</button>
|
<button>Копировать</button>
|
||||||
<h3>Веб-прокси</h3>
|
<h3>Веб-прокси</h3>
|
||||||
<a href="https://www.vpnbook.com/webproxy">vpnbook [COPY]</a><br/>
|
<a href="https://www.vpnbook.com/webproxy">vpnbook [COPY]</a><br/>
|
||||||
<a href="https://webproxy.com/browse.php?u=${url}">webproxy.com</a><br/>
|
<a href="https://webproxy.com/browse.php?u=${url}">webproxy.com [COPY]</a><br/>
|
||||||
<a href="http://buka.link/browse.php?u=${url.replace(/\?.+/,'')}">buka.link [AVAST, COPY]</a><br/>
|
<a href="http://buka.link/browse.php?u=${url.replace(/\?.+/,'')}">buka.link [AVAST, COPY]</a><br/>
|
||||||
<a href="https://hide.me/en/proxy">hide.me [COPY]</a><br/>
|
<a href="https://hide.me/en/proxy">hide.me [COPY]</a><br/>
|
||||||
<a href="https://www.hidemyass.com/proxy">Hide my ass [COPY]</a><br/>
|
<a href="https://www.hidemyass.com/proxy">Hide my ass [COPY]</a><br/>
|
||||||
|
<a href="http://usafastproxy.com">USA Fast Proxy [COPY, HTTP, GLYPE]</a><br/>
|
||||||
|
<a href="http://www.mysafesurfing.com">My Safe Surfing [COPY, HTTP, GLYPE]</a><br/>
|
||||||
<a href="https://www.google.com/search?q=webproxy">Другие</a>
|
<a href="https://www.google.com/search?q=webproxy">Другие</a>
|
||||||
<h3>Из кэша поисковиков</h3>
|
<h3>Из кэша поисковиков</h3>
|
||||||
<a href="https://webcache.googleusercontent.com/search?q=cache:${url}">Google</a></br>
|
<a href="https://webcache.googleusercontent.com/search?q=cache:${url}">Google</a></br>
|
||||||
|
@ -35,6 +37,6 @@ document.body.innerHTML = `
|
||||||
'>Сайт доступен из-за границы? host-tracker</a>
|
'>Сайт доступен из-за границы? host-tracker</a>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
var _ = document.querySelector('input');
|
const _ = document.querySelector('input');
|
||||||
_.onfocus = function() { this.select() };
|
_.onfocus = function() { this.select() };
|
||||||
document.querySelector('button').onclick = () => {_.focus(); document.execCommand('copy')};
|
document.querySelector('button').onclick = () => {_.focus(); document.execCommand('copy')};
|
||||||
|
|
BIN
extensions/chromium/minimalistic-pac-setter/kasparov.ru-title.jpg
Executable file
BIN
extensions/chromium/minimalistic-pac-setter/kasparov.ru-title.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 77 KiB |
BIN
extensions/chromium/minimalistic-pac-setter/krrb-kiwiirc-irccloud-slideshare.jpg
Executable file
BIN
extensions/chromium/minimalistic-pac-setter/krrb-kiwiirc-irccloud-slideshare.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 306 KiB |
BIN
extensions/chromium/minimalistic-pac-setter/slideshare-menu.jpg
Executable file
BIN
extensions/chromium/minimalistic-pac-setter/slideshare-menu.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
Loading…
Reference in New Issue
Block a user