mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-24 02:13:43 +03:00
Counter abuse, add locales, change description, add utils.messages, change disabling to warning message if no-control, add mask and grayscale icons
This commit is contained in:
parent
dc47210ad9
commit
34c94eb3d3
|
@ -9,6 +9,25 @@ window.utils = {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
messages: {
|
||||||
|
|
||||||
|
searchSettingsUrlFor(niddle) {
|
||||||
|
|
||||||
|
return 'chrome://settings/search#' + (chrome.i18n.getMessage(niddle) || niddle);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
whichExtensionHtml() {
|
||||||
|
|
||||||
|
return chrome.i18n.getMessage('noControl') +
|
||||||
|
` <a href="${ this.searchSettingsUrlFor('proxy') }">
|
||||||
|
${ chrome.i18n.getMessage('which') }
|
||||||
|
</a>`;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.apis = {};
|
window.apis = {};
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
for(const prop in value) {
|
for(const prop in value) {
|
||||||
if (/^[A-Z]/.test(prop)) {
|
if (/^[A-Z]/.test(prop)) {
|
||||||
|
console.log(prop);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
alt[prop] = value[prop];
|
alt[prop] = value[prop];
|
||||||
|
@ -80,7 +81,7 @@
|
||||||
viewError(err) {
|
viewError(err) {
|
||||||
|
|
||||||
openAndFocus(
|
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);
|
this.ifNotControlled = window.utils.areSettingsNotControlledFor(details);
|
||||||
if (this.ifNotControlled) {
|
if (this.ifNotControlled) {
|
||||||
chrome.browserAction.disable();
|
chrome.browserAction.setIcon( {path: './icons/default-grayscale-128.png'} );
|
||||||
} else {
|
} else {
|
||||||
chrome.browserAction.enable();
|
chrome.browserAction.setIcon( {path: './icons/default-128.png'} );
|
||||||
}
|
}
|
||||||
return this.ifNotControlled;
|
return this.ifNotControlled;
|
||||||
|
|
||||||
|
@ -150,6 +151,7 @@
|
||||||
requireInteraction: true,
|
requireInteraction: true,
|
||||||
type: 'basic',
|
type: 'basic',
|
||||||
iconUrl: './icons/' + icon,
|
iconUrl: './icons/' + icon,
|
||||||
|
appIconMaskUrl: './icons/default-mask-128.png',
|
||||||
isClickable: true,
|
isClickable: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -186,7 +188,9 @@
|
||||||
|
|
||||||
const handlers = window.apis.errorHandlers;
|
const handlers = window.apis.errorHandlers;
|
||||||
|
|
||||||
// INIT
|
// INITIALIZATION
|
||||||
|
// ==============
|
||||||
|
|
||||||
chrome.proxy.settings.get(
|
chrome.proxy.settings.get(
|
||||||
{},
|
{},
|
||||||
(details) => handlers.isNotControlled(details)
|
(details) => handlers.isNotControlled(details)
|
||||||
|
@ -196,7 +200,7 @@
|
||||||
|
|
||||||
chrome.notifications.clear(notId);
|
chrome.notifications.clear(notId);
|
||||||
if(notId === 'no-control') {
|
if(notId === 'no-control') {
|
||||||
return openAndFocus('chrome://settings/#proxy');
|
return openAndFocus( window.utils.messages.searchSettingsUrlFor('proxy') );
|
||||||
}
|
}
|
||||||
const errors = handlers.idToError;
|
const errors = handlers.idToError;
|
||||||
handlers.viewError(errors);
|
handlers.viewError(errors);
|
||||||
|
@ -230,10 +234,12 @@
|
||||||
console.log('Proxy settings changed.', details);
|
console.log('Proxy settings changed.', details);
|
||||||
const noCon = 'no-control';
|
const noCon = 'no-control';
|
||||||
if ( handlers.isNotControlled(details) ) {
|
if ( handlers.isNotControlled(details) ) {
|
||||||
console.log(details);
|
handlers.mayNotify(
|
||||||
handlers.mayNotify(noCon, 'Другое расширение контролирует прокси',
|
noCon,
|
||||||
'Какое?',
|
chrome.i18n.getMessage('noControl'),
|
||||||
'no-control-128.png');
|
chrome.i18n.getMessage('which'),
|
||||||
|
'no-control-128.png'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
chrome.notifications.clear( noCon );
|
chrome.notifications.clear( noCon );
|
||||||
}
|
}
|
||||||
|
|
|
@ -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'],
|
proxyHosts: ['proxy.antizapret.prostovpn.org', 'gw2.anticenz.org'],
|
||||||
proxyIps: {
|
proxyIps: {
|
||||||
'195.123.209.38': 'proxy.antizapret.prostovpn.org',
|
'195.123.209.38': 'proxy.antizapret.prostovpn.org',
|
||||||
|
@ -267,6 +271,11 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
_pacUpdatePeriodInMinutes: 12*60,
|
_pacUpdatePeriodInMinutes: 12*60,
|
||||||
|
get pacUpdatePeriodInMinutes() {
|
||||||
|
|
||||||
|
return this._pacUpdatePeriodInMinutes;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
setAlarms() {
|
setAlarms() {
|
||||||
|
|
||||||
|
@ -454,7 +463,7 @@
|
||||||
|
|
||||||
if ( window.utils.areSettingsNotControlledFor( details ) ) {
|
if ( window.utils.areSettingsNotControlledFor( details ) ) {
|
||||||
console.warn('Failed, other extension is in control.');
|
console.warn('Failed, other extension is in control.');
|
||||||
return cb({clarification: {message: 'Настройки прокси контролирует другое расширение. <a href="chrome://settings/search#proxy">Какое?</a>'}});
|
return cb({clarification: {message: window.utils.messages.whichExtensionHtml() }});
|
||||||
}
|
}
|
||||||
console.log('Successfuly set PAC in proxy settings..');
|
console.log('Successfuly set PAC in proxy settings..');
|
||||||
cb();
|
cb();
|
||||||
|
|
|
@ -48,8 +48,7 @@ window.tabWithError2ip = {}; // For errors only: Error? -> Check this IP!
|
||||||
chrome.webRequest.onErrorOccurred.addListener(
|
chrome.webRequest.onErrorOccurred.addListener(
|
||||||
(requestDetails) =>
|
(requestDetails) =>
|
||||||
isInsideTabWithIp(requestDetails)
|
isInsideTabWithIp(requestDetails)
|
||||||
&& isProxiedAndInformed(requestDetails)
|
&& isProxiedAndInformed(requestDetails),
|
||||||
,
|
|
||||||
{urls: ['<all_urls>']}
|
{urls: ['<all_urls>']}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -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?"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"extName": {
|
||||||
|
"message": "Обход блокировок Рунета"
|
||||||
|
},
|
||||||
|
"extDesc": {
|
||||||
|
"message": "Обход интернет-цензуры в России:"
|
||||||
|
},
|
||||||
|
"proxy": {
|
||||||
|
"message": "прокси"
|
||||||
|
},
|
||||||
|
"noControl": {
|
||||||
|
"message": "Другое расширение контролирует настройки прокси!"
|
||||||
|
},
|
||||||
|
"which": {
|
||||||
|
"message": "Какое?"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
|
@ -1,9 +1,10 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
|
|
||||||
"name": "Обход блокировок Рунета 0.15",
|
"name": "__MSG_extName__",
|
||||||
"description": "Аргументы против цензуры: https://git.io/vEkI9",
|
"default_locale": "en",
|
||||||
"version": "0.0.0.15",
|
"description": "__MSG_extDesc__ https://rebrand.ly/ac-wiki",
|
||||||
|
"version": "0.0.0.16",
|
||||||
"icons": {
|
"icons": {
|
||||||
"128": "/icons/default-128.png"
|
"128": "/icons/default-128.png"
|
||||||
},
|
},
|
||||||
|
@ -22,7 +23,13 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
"background": {
|
"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": {
|
"browser_action": {
|
||||||
"default_title": "Этот сайт благословлён",
|
"default_title": "Этот сайт благословлён",
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html style="display: none">
|
||||||
<head>
|
<head>
|
||||||
<title>Выбор провайдера PAC</title>
|
<title>Выбор провайдера PAC</title>
|
||||||
<style>
|
<style>
|
||||||
|
div {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
label {
|
label {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
@ -44,20 +48,29 @@
|
||||||
}
|
}
|
||||||
hr {
|
hr {
|
||||||
border-width: 1px 0 0 0;
|
border-width: 1px 0 0 0;
|
||||||
|
margin: 0.6em 0;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
#configs-panel > header {
|
#configs-panel > header {
|
||||||
margin: 0.6em 0 0.4em;
|
margin: 0 0 0.4em;
|
||||||
|
}
|
||||||
|
.if-not-controlled {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<span class="if-not-controlled">
|
||||||
|
<span id="which-extension"></span>
|
||||||
|
<hr style="border-color: red; border-style: solid;"/>
|
||||||
|
</span>
|
||||||
<ul id="list-of-providers">
|
<ul id="list-of-providers">
|
||||||
<li><input type="radio" name="pacProvider" id="none" checked> <label for="none">Отключить</label></li>
|
<li><input type="radio" name="pacProvider" id="none" checked> <label for="none">Отключить</label></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div style="white-space: nowrap">
|
<div style="white-space: nowrap">
|
||||||
Обновлялись: <span class="update-date">...</span>
|
Обновлялись: <span class="update-date">...</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="status">Загрузка...</div>
|
<span id="status">Загрузка...</span>
|
||||||
<hr/>
|
<hr/>
|
||||||
<div id="configs-panel">
|
<div id="configs-panel">
|
||||||
<header>Я ❤️ уведомления:</header>
|
<header>Я ❤️ уведомления:</header>
|
||||||
|
|
|
@ -7,17 +7,12 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
||||||
|
|
||||||
const setStatusTo = (msg) => {
|
const setStatusTo = (msg) => {
|
||||||
|
|
||||||
const status = getStatus();
|
getStatus().innerHTML = msg;
|
||||||
if (msg) {
|
|
||||||
status.classList.remove('off');
|
|
||||||
status.innerHTML = msg;
|
|
||||||
} else {
|
|
||||||
status.classList.add('off');
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const antiCensorRu = backgroundPage.apis.antiCensorRu;
|
const antiCensorRu = backgroundPage.apis.antiCensorRu;
|
||||||
|
const errorHandlers = backgroundPage.apis.errorHandlers;
|
||||||
|
|
||||||
// SET DATE
|
// SET DATE
|
||||||
|
|
||||||
|
@ -26,15 +21,14 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
||||||
let dateForUser = 'никогда';
|
let dateForUser = 'никогда';
|
||||||
if( antiCensorRu.lastPacUpdateStamp ) {
|
if( antiCensorRu.lastPacUpdateStamp ) {
|
||||||
let diff = Date.now() - antiCensorRu.lastPacUpdateStamp;
|
let diff = Date.now() - antiCensorRu.lastPacUpdateStamp;
|
||||||
let units = ' мс';
|
let units = 'мс';
|
||||||
const gauges = [
|
const gauges = [
|
||||||
[1000, ' с'],
|
[1000, 'с'],
|
||||||
[60, ' мин'],
|
[60, 'мин'],
|
||||||
[60, ' ч'],
|
[60, 'ч'],
|
||||||
[24, ' дн'],
|
[24, 'дн'],
|
||||||
[7, ' недель'],
|
[7, ' недель'],
|
||||||
[4, ' месяцев'],
|
[4, ' месяцев'],
|
||||||
[12, ' г'],
|
|
||||||
];
|
];
|
||||||
for(const g of gauges) {
|
for(const g of gauges) {
|
||||||
const diffy = Math.floor(diff / g[0]);
|
const diffy = Math.floor(diff / g[0]);
|
||||||
|
@ -47,7 +41,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateElement = document.querySelector('.update-date');
|
const dateElement = document.querySelector('.update-date');
|
||||||
dateElement.innerText = dateForUser;
|
dateElement.innerText = dateForUser + ' / T=' + (antiCensorRu.pacUpdatePeriodInMinutes/60) + 'ч';
|
||||||
dateElement.title = new Date(antiCensorRu.lastPacUpdateStamp)
|
dateElement.title = new Date(antiCensorRu.lastPacUpdateStamp)
|
||||||
.toLocaleString('ru-RU');
|
.toLocaleString('ru-RU');
|
||||||
|
|
||||||
|
@ -95,7 +89,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
||||||
);
|
);
|
||||||
getStatus().querySelector('.link-button').onclick = function() {
|
getStatus().querySelector('.link-button').onclick = function() {
|
||||||
|
|
||||||
backgroundPage.apis.errorHandlers.viewError(err);
|
errorHandlers.viewError(err);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -180,7 +174,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
const conpanel = document.getElementById('list-of-handlers');
|
const conpanel = document.getElementById('list-of-handlers');
|
||||||
backgroundPage.apis.errorHandlers.getEventsMap().forEach( (value, name) => {
|
errorHandlers.getEventsMap().forEach( (value, name) => {
|
||||||
|
|
||||||
const li = document.createElement('li');
|
const li = document.createElement('li');
|
||||||
li.innerHTML = `
|
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('');
|
setStatusTo('');
|
||||||
|
|
||||||
if (antiCensorRu.ifFirstInstall) {
|
if (antiCensorRu.ifFirstInstall) {
|
||||||
const id = antiCensorRu.currentPacProviderKey || 'none';
|
const id = antiCensorRu.currentPacProviderKey || 'none';
|
||||||
document.querySelector('#update-' + id).click();
|
document.querySelector('#update-' + id).click();
|
||||||
}
|
}
|
||||||
|
document.documentElement.style.display = '';
|
||||||
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,11 +4,13 @@ In popup links are not clickable at all, fix it.
|
||||||
On other pages "chrome://" links are not clickable, fix it.
|
On other pages "chrome://" links are not clickable, fix it.
|
||||||
Use only if really required because of performance penalty.
|
Use only if really required because of performance penalty.
|
||||||
*/
|
*/
|
||||||
|
{
|
||||||
|
|
||||||
const target = document.getElementById('status');
|
const target = document.documentElement;
|
||||||
|
|
||||||
const updateLinks = () => {
|
const updateLinks = () => {
|
||||||
|
|
||||||
|
console.log('UPDATE');
|
||||||
const links = document.querySelectorAll('a:not([href=""])');
|
const links = document.querySelectorAll('a:not([href=""])');
|
||||||
for (let i = 0; i < links.length; i++) {
|
for (let i = 0; i < links.length; i++) {
|
||||||
const ln = links[i];
|
const ln = links[i];
|
||||||
|
@ -21,14 +23,16 @@ const updateLinks = () => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
new MutationObserver( updateLinks )
|
new MutationObserver( updateLinks )
|
||||||
.observe(target, {
|
.observe(target, {
|
||||||
attributes: false,
|
attributes: true,
|
||||||
subtree: true,
|
subtree: true,
|
||||||
childList: true,
|
childList: true,
|
||||||
characterData: false,
|
characterData: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', updateLinks);
|
document.addEventListener('DOMContentLoaded', updateLinks);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user