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:
Ilya Ig. Petrov 2016-12-22 15:49:53 +00:00
parent dc47210ad9
commit 34c94eb3d3
12 changed files with 154 additions and 58 deletions

View File

@ -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 = {};

View File

@ -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 );
}

View File

@ -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: 'Настройки прокси контролирует другое расширение. <a href="chrome://settings/search#proxy">Какое?</a>'}});
return cb({clarification: {message: window.utils.messages.whichExtensionHtml() }});
}
console.log('Successfuly set PAC in proxy settings..');
cb();

View File

@ -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: ['<all_urls>']}
);

View File

@ -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?"
}
}

View File

@ -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

View File

@ -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": "Этот сайт благословлён",

View File

@ -1,8 +1,12 @@
<!DOCTYPE html>
<html>
<html style="display: none">
<head>
<title>Выбор провайдера PAC</title>
<style>
div {
margin: 0;
padding: 0;
}
label {
user-select: none;
}
@ -44,20 +48,29 @@
}
hr {
border-width: 1px 0 0 0;
margin: 0.6em 0;
padding: 0;
}
#configs-panel > header {
margin: 0.6em 0 0.4em;
margin: 0 0 0.4em;
}
.if-not-controlled {
display: none;
}
</style>
</head>
<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">
<li><input type="radio" name="pacProvider" id="none" checked> <label for="none">Отключить</label></li>
</ul>
<div style="white-space: nowrap">
Обновлялись: <span class="update-date">...</span>
</div>
<div id="status">Загрузка...</div>
<span id="status">Загрузка...</span>
<hr/>
<div id="configs-panel">
<header>Я ❤️ уведомления:</header>

View File

@ -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
@ -34,7 +29,6 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
[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 = '';
})
);

View File

@ -4,11 +4,13 @@ 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 = () => {
console.log('UPDATE');
const links = document.querySelectorAll('a:not([href=""])');
for (let i = 0; i < links.length; i++) {
const ln = links[i];
@ -25,10 +27,12 @@ const updateLinks = () => {
new MutationObserver( updateLinks )
.observe(target, {
attributes: false,
attributes: true,
subtree: true,
childList: true,
characterData: false,
});
document.addEventListener('DOMContentLoaded', updateLinks);
}