mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-24 02:13:43 +03:00
No-control checks prev state, change timeouted
This commit is contained in:
parent
a6b5b7ab57
commit
893fd94c17
|
@ -39,32 +39,29 @@
|
|||
|
||||
// Chrome API calls your cb in a context different from the point of API
|
||||
// method invokation.
|
||||
let err = chrome.runtime.lastError || chrome.extension.lastError;
|
||||
if (err) {
|
||||
err = new Error(err.message); // Add stack.
|
||||
console.warn('API returned error:', err);
|
||||
const err = chrome.runtime.lastError || chrome.extension.lastError;
|
||||
if (!err) {
|
||||
return;
|
||||
}
|
||||
return err;
|
||||
console.warn('API returned error:', err);
|
||||
return new Error(err.message); // Add stack.
|
||||
|
||||
},
|
||||
|
||||
timeouted(cb = self.mandatory) {
|
||||
|
||||
return (...args) => setTimeout(cb.bind(null, ...args), 0)
|
||||
// setTimeout fixes error context, see bug #357568.
|
||||
return (...args) => setTimeout(() => cb(...args), 0);
|
||||
|
||||
},
|
||||
|
||||
chromified(cb = self.mandatory(), ...replaceArgs) {
|
||||
chromified(cb = self.mandatory()) {
|
||||
|
||||
// Take error first callback and convert it to chrome API callback.
|
||||
return function(...args) {
|
||||
|
||||
if (replaceArgs.length) {
|
||||
args = replaceArgs;
|
||||
}
|
||||
const err = self.checkChromeError();
|
||||
// setTimeout fixes error context.
|
||||
setTimeout( cb.bind(null, err, ...args), 0 );
|
||||
self.timeouted(cb)(err, ...args);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -67,13 +67,9 @@
|
|||
|
||||
viewError(type = window.utils.mandatory(), err) {
|
||||
|
||||
let errors = {};
|
||||
if (err) {
|
||||
errors[type] = err;
|
||||
} else {
|
||||
errors = this.idToError;
|
||||
}
|
||||
const errors = err ? { [type]: err } : this.idToError;
|
||||
const json = JSON.stringify(errors, errorJsonReplacer, 0);
|
||||
|
||||
openAndFocus(
|
||||
'http://rebrand.ly/ac-error/?json=' + encodeURIComponent(json) +
|
||||
(type ? '&type=' + encodeURIComponent(type) : '') +
|
||||
|
@ -144,7 +140,7 @@
|
|||
icon = 'default-128.png',
|
||||
context = extName,
|
||||
ifSticky = true,
|
||||
}
|
||||
} = {}
|
||||
) {
|
||||
|
||||
if ( !this.isOn(id) ) {
|
||||
|
@ -245,7 +241,8 @@
|
|||
|
||||
console.log('Proxy settings changed.', details);
|
||||
const noCon = 'no-control';
|
||||
if ( !handlers.isControllable(details) ) {
|
||||
const ifWasControllable = handler.ifControllable;
|
||||
if ( !handlers.isControllable(details) && ifWasControllable ) {
|
||||
handlers.mayNotify(
|
||||
noCon,
|
||||
chrome.i18n.getMessage('noControl'),
|
||||
|
|
|
@ -116,10 +116,8 @@
|
|||
'https://dns.google.com/resolve?type=' + type + '&name=' + host,
|
||||
(err, res) => {
|
||||
|
||||
console.log('After GET...');
|
||||
if (res) {
|
||||
try {
|
||||
console.log('Parsing JSON...');
|
||||
res = JSON.parse(res);
|
||||
console.log('JSON parsed.');
|
||||
if (err || res.Status) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user