Fix apis error context with timeout, change default locale, colorize icons
|
@ -11,7 +11,7 @@ window.utils = {
|
|||
|
||||
messages: {
|
||||
|
||||
searchSettingsUrlFor(niddle) {
|
||||
searchSettingsForUrl(niddle) {
|
||||
|
||||
return 'chrome://settings/search#' + (chrome.i18n.getMessage(niddle) || niddle);
|
||||
|
||||
|
@ -20,7 +20,7 @@ window.utils = {
|
|||
whichExtensionHtml() {
|
||||
|
||||
return chrome.i18n.getMessage('noControl') +
|
||||
` <a href="${ this.searchSettingsUrlFor('proxy') }">
|
||||
` <a href="${ this.searchSettingsForUrl('proxy') }">
|
||||
${ chrome.i18n.getMessage('which') }
|
||||
</a>`;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
for(const prop in value) {
|
||||
if (/^[A-Z]/.test(prop)) {
|
||||
console.log(prop);
|
||||
// MOUSEMOVE, CLICK, KEYUP, NONE, etc.
|
||||
continue;
|
||||
}
|
||||
alt[prop] = value[prop];
|
||||
|
@ -78,10 +78,11 @@
|
|||
|
||||
window.apis.errorHandlers = {
|
||||
|
||||
viewError(err) {
|
||||
viewErrorVoid(err) {
|
||||
|
||||
const json = JSON.stringify(err, errorJsonReplacer, 0);
|
||||
openAndFocus(
|
||||
'https://rebrand.ly/ac-error/?' + btoa(JSON.stringify(err, errorJsonReplacer, 0))
|
||||
'https://rebrand.ly/ac-error/?' + btoa(json)
|
||||
);
|
||||
|
||||
},
|
||||
|
@ -96,7 +97,7 @@
|
|||
|
||||
},
|
||||
|
||||
switch(onOffStr, eventName) {
|
||||
switchVoid(onOffStr, eventName) {
|
||||
|
||||
if (!['on', 'off'].includes(onOffStr)) {
|
||||
throw new TypeError('First argument bust be "on" or "off".');
|
||||
|
@ -131,7 +132,7 @@
|
|||
|
||||
idToError: {},
|
||||
|
||||
mayNotify(
|
||||
mayNotifyVoid(
|
||||
id, title, errOrMessage,
|
||||
icon = 'default-128.png',
|
||||
context = extName
|
||||
|
@ -158,19 +159,19 @@
|
|||
|
||||
},
|
||||
|
||||
installListenersOn(win, name, cb) {
|
||||
installListenersOnAsync(win, name, cb) {
|
||||
|
||||
win.addEventListener('error', (errEvent) => {
|
||||
|
||||
console.warn(name + ':GLOBAL ERROR', errEvent);
|
||||
this.mayNotify('ext-error', 'Ошибка расширения', errEvent,
|
||||
this.mayNotifyVoid('ext-error', 'Ошибка расширения', errEvent,
|
||||
'ext-error-128.png');
|
||||
|
||||
});
|
||||
|
||||
win.addEventListener('unhandledrejection', (event) => {
|
||||
|
||||
console.warn(name + ':Unhandled rejection. Throwing error.');
|
||||
console.warn(name + ': Unhandled rejection. Throwing error.');
|
||||
event.preventDefault();
|
||||
console.log('ev', event);
|
||||
throw event.reason;
|
||||
|
@ -200,14 +201,14 @@
|
|||
|
||||
chrome.notifications.clear(notId);
|
||||
if(notId === 'no-control') {
|
||||
return openAndFocus( window.utils.messages.searchSettingsUrlFor('proxy') );
|
||||
return openAndFocus( window.utils.messages.searchSettingsForUrl('proxy') );
|
||||
}
|
||||
const errors = handlers.idToError;
|
||||
handlers.viewError(errors);
|
||||
handlers.viewErrorVoid(errors);
|
||||
|
||||
});
|
||||
|
||||
handlers.installListenersOn(window, 'BG');
|
||||
handlers.installListenersOnAsync(window, 'BG');
|
||||
|
||||
chrome.proxy.onProxyError.addListener((details) => {
|
||||
|
||||
|
@ -222,7 +223,7 @@
|
|||
*/
|
||||
console.warn('PAC ERROR', details);
|
||||
// TOOD: add "view pac script at this line" button.
|
||||
handlers.mayNotify('pac-error', 'Ошибка PAC!',
|
||||
handlers.mayNotifyVoid('pac-error', 'Ошибка PAC!',
|
||||
details.error + '\n' + details.details,
|
||||
'pac-error-128.png'
|
||||
);
|
||||
|
@ -234,7 +235,7 @@
|
|||
console.log('Proxy settings changed.', details);
|
||||
const noCon = 'no-control';
|
||||
if ( handlers.isNotControlled(details) ) {
|
||||
handlers.mayNotify(
|
||||
handlers.mayNotifyVoid(
|
||||
noCon,
|
||||
chrome.i18n.getMessage('noControl'),
|
||||
chrome.i18n.getMessage('which'),
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
See errorHandlers api for more.
|
||||
|
||||
*/
|
||||
|
||||
{ // Private namespace starts.
|
||||
|
||||
function mandatory() {
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
/* `setTimeout` changes context of execution from other window
|
||||
(e.g. popup) to background window, so we may catch errors
|
||||
in bg error handlers.
|
||||
More: https://bugs.chromium.org/p/chromium/issues/detail?id=357568
|
||||
setTimeout is applied to Async methods only (name ends with Async)
|
||||
*/
|
||||
// Fix error context of methods of all APIs.
|
||||
|
||||
for(const apiName of Object.keys(window.apis)) {
|
||||
const api = window.apis[apiName];
|
||||
for(const prop of Object.keys(api)) {
|
||||
const method = api[prop];
|
||||
if ( !(
|
||||
typeof(api[prop]) === 'function'
|
||||
&& ['Async', 'Void'].some( (suff) => method.name.endsWith(suff) )
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
api[prop] = function(...args) {
|
||||
setTimeout(method.bind(this, ...args), 0);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
"message": "Runet Censorship Bypass"
|
||||
},
|
||||
"extDesc": {
|
||||
"message": "Circumvent Russian internet censorship:"
|
||||
"message": "Circumvent Russian Internet Censorship: https://rebrand.ly/ac-wiki"
|
||||
},
|
||||
"proxy": {
|
||||
"message": "proxy"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"message": "Обход блокировок Рунета"
|
||||
},
|
||||
"extDesc": {
|
||||
"message": "Обход интернет-цензуры в России:"
|
||||
"message": "Обход интернет-цензуры в России: https://rebrand.ly/ac-wiki"
|
||||
},
|
||||
"proxy": {
|
||||
"message": "прокси"
|
||||
|
|
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.6 KiB |
|
@ -2,8 +2,8 @@
|
|||
"manifest_version": 2,
|
||||
|
||||
"name": "__MSG_extName__",
|
||||
"default_locale": "en",
|
||||
"description": "__MSG_extDesc__ https://rebrand.ly/ac-wiki",
|
||||
"default_locale": "ru",
|
||||
"description": "__MSG_extDesc__",
|
||||
"version": "0.0.0.16",
|
||||
"icons": {
|
||||
"128": "/icons/default-128.png"
|
||||
|
@ -27,6 +27,7 @@
|
|||
"00-init-apis.js",
|
||||
"11-api-error-handlers.js",
|
||||
"12-api-sync-pac-script-with-pac-provider.js",
|
||||
"20-api-fixes.js",
|
||||
"30-block-informer.js",
|
||||
"40-context-menus.js"
|
||||
]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
||||
backgroundPage.apis.errorHandlers.installListenersOn(window, 'POPUP', () => {
|
||||
backgroundPage.apis.errorHandlers.installListenersOnAsync(window, 'POPUP', () => {
|
||||
|
||||
const getStatus = () => document.querySelector('#status');
|
||||
|
||||
|
@ -41,7 +41,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
}
|
||||
|
||||
const dateElement = document.querySelector('.update-date');
|
||||
dateElement.innerText = dateForUser + ' / T=' + (antiCensorRu.pacUpdatePeriodInMinutes/60) + 'ч';
|
||||
dateElement.innerText = dateForUser + ' / ' + (antiCensorRu.pacUpdatePeriodInMinutes/60) + 'ч';
|
||||
dateElement.title = new Date(antiCensorRu.lastPacUpdateStamp)
|
||||
.toLocaleString('ru-RU');
|
||||
|
||||
|
@ -89,7 +89,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
);
|
||||
getStatus().querySelector('.link-button').onclick = function() {
|
||||
|
||||
errorHandlers.viewError(err);
|
||||
errorHandlers.viewErrorVoid(err);
|
||||
return false;
|
||||
|
||||
};
|
||||
|
@ -185,7 +185,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
box.onclick = function() {
|
||||
|
||||
const id = this.id.replace('if-on-', '');
|
||||
backgroundPage.apis.errorHandlers.switch(
|
||||
return backgroundPage.apis.errorHandlers.switchVoid(
|
||||
this.checked ? 'on' : 'off',
|
||||
id
|
||||
);
|
||||
|
@ -196,7 +196,6 @@ 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) => {
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ Use only if really required because of performance penalty.
|
|||
|
||||
const updateLinks = () => {
|
||||
|
||||
console.log('UPDATE');
|
||||
const links = document.querySelectorAll('a:not([href=""])');
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
const ln = links[i];
|
||||
|
|