diff --git a/extensions/chromium/minimalistic-pac-setter/extension/00-init-apis.js b/extensions/chromium/minimalistic-pac-setter/extension/00-init-apis.js
index e429962..deeea8e 100644
--- a/extensions/chromium/minimalistic-pac-setter/extension/00-init-apis.js
+++ b/extensions/chromium/minimalistic-pac-setter/extension/00-init-apis.js
@@ -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') +
- `
+ `
${ chrome.i18n.getMessage('which') }
`;
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js b/extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js
index 8346058..ab5b7af 100644
--- a/extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js
+++ b/extensions/chromium/minimalistic-pac-setter/extension/11-api-error-handlers.js
@@ -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'),
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js b/extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js
index 5dfef0f..3b033a4 100644
--- a/extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js
+++ b/extensions/chromium/minimalistic-pac-setter/extension/12-api-sync-pac-script-with-pac-provider.js
@@ -18,6 +18,7 @@
See errorHandlers api for more.
*/
+
{ // Private namespace starts.
function mandatory() {
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/20-api-fixes.js b/extensions/chromium/minimalistic-pac-setter/extension/20-api-fixes.js
new file mode 100644
index 0000000..4fe6358
--- /dev/null
+++ b/extensions/chromium/minimalistic-pac-setter/extension/20-api-fixes.js
@@ -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);
+ };
+ }
+}
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/_locales/en/messages.json b/extensions/chromium/minimalistic-pac-setter/extension/_locales/en/messages.json
index c9d800a..8ee2be9 100644
--- a/extensions/chromium/minimalistic-pac-setter/extension/_locales/en/messages.json
+++ b/extensions/chromium/minimalistic-pac-setter/extension/_locales/en/messages.json
@@ -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"
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/_locales/ru/messages.json b/extensions/chromium/minimalistic-pac-setter/extension/_locales/ru/messages.json
index 53784a1..a19e414 100644
--- a/extensions/chromium/minimalistic-pac-setter/extension/_locales/ru/messages.json
+++ b/extensions/chromium/minimalistic-pac-setter/extension/_locales/ru/messages.json
@@ -3,7 +3,7 @@
"message": "Обход блокировок Рунета"
},
"extDesc": {
- "message": "Обход интернет-цензуры в России:"
+ "message": "Обход интернет-цензуры в России: https://rebrand.ly/ac-wiki"
},
"proxy": {
"message": "прокси"
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/_ext-error-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/_ext-error-128.png
new file mode 100644
index 0000000..76a65ab
Binary files /dev/null and b/extensions/chromium/minimalistic-pac-setter/extension/icons/_ext-error-128.png differ
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/_no-control-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/_no-control-128.png
new file mode 100644
index 0000000..8256c6d
Binary files /dev/null and b/extensions/chromium/minimalistic-pac-setter/extension/icons/_no-control-128.png differ
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/_pac-error-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/_pac-error-128.png
new file mode 100644
index 0000000..15684ce
Binary files /dev/null and b/extensions/chromium/minimalistic-pac-setter/extension/icons/_pac-error-128.png differ
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/ext-error-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/ext-error-128.png
index 76a65ab..8bb4857 100644
Binary files a/extensions/chromium/minimalistic-pac-setter/extension/icons/ext-error-128.png and b/extensions/chromium/minimalistic-pac-setter/extension/icons/ext-error-128.png differ
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/no-control-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/no-control-128.png
index 8256c6d..b288b59 100644
Binary files a/extensions/chromium/minimalistic-pac-setter/extension/icons/no-control-128.png and b/extensions/chromium/minimalistic-pac-setter/extension/icons/no-control-128.png differ
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/icons/pac-error-128.png b/extensions/chromium/minimalistic-pac-setter/extension/icons/pac-error-128.png
index 15684ce..c696bf4 100644
Binary files a/extensions/chromium/minimalistic-pac-setter/extension/icons/pac-error-128.png and b/extensions/chromium/minimalistic-pac-setter/extension/icons/pac-error-128.png differ
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/manifest.json b/extensions/chromium/minimalistic-pac-setter/extension/manifest.json
index 44f4b7c..f313037 100755
--- a/extensions/chromium/minimalistic-pac-setter/extension/manifest.json
+++ b/extensions/chromium/minimalistic-pac-setter/extension/manifest.json
@@ -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"
]
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.js b/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.js
index f197da4..9713bb7 100755
--- a/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.js
+++ b/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/index.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) => {
diff --git a/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/keep-links-clickable.js b/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/keep-links-clickable.js
index 509abd3..8d139cf 100644
--- a/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/keep-links-clickable.js
+++ b/extensions/chromium/minimalistic-pac-setter/extension/pages/choose-pac-provider/keep-links-clickable.js
@@ -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];