mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-24 02:13:43 +03:00
Check control manually after changes
This commit is contained in:
parent
893fd94c17
commit
bfdedd10f7
|
@ -4,7 +4,7 @@
|
|||
|
||||
const timeouted = window.utils.timeouted;
|
||||
|
||||
function errorJsonReplacer(key, value) {
|
||||
const errorJsonReplacer = function errorJsonReplacer(key, value) {
|
||||
|
||||
// fooWindow.ErrorEvent !== barWindow.ErrorEvent
|
||||
if (!( value && value.constructor
|
||||
|
@ -47,7 +47,7 @@
|
|||
|
||||
return alt;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const openAndFocus = function openAndFocus(url) {
|
||||
|
||||
|
@ -60,6 +60,7 @@
|
|||
|
||||
const ifPrefix = 'if-on-';
|
||||
const extName = chrome.runtime.getManifest().name;
|
||||
const extVersion = chrome.runtime.getManifest().version.replace(/\d+\.\d+\./g, '');
|
||||
|
||||
window.apis.errorHandlers = {
|
||||
|
||||
|
@ -112,6 +113,7 @@
|
|||
|
||||
isControllable(details) {
|
||||
|
||||
console.log('IS',details);
|
||||
this.ifControllable = window.utils.areSettingsControllableFor(details);
|
||||
|
||||
if (this.ifControllable) {
|
||||
|
@ -132,13 +134,36 @@
|
|||
|
||||
},
|
||||
|
||||
isControlled(details) {
|
||||
|
||||
this.isControllable(details);
|
||||
return this.ifControlled;
|
||||
|
||||
},
|
||||
|
||||
updateControlState(cb = throwIfError) {
|
||||
|
||||
chrome.proxy.settings.get(
|
||||
{},
|
||||
timeouted(
|
||||
(details) => {
|
||||
|
||||
this.isControllable(details);
|
||||
cb();
|
||||
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
},
|
||||
|
||||
idToError: {},
|
||||
|
||||
mayNotify(
|
||||
id, title, errOrMessage,
|
||||
{
|
||||
icon = 'default-128.png',
|
||||
context = extName,
|
||||
context = extName + ' ' + extVersion,
|
||||
ifSticky = true,
|
||||
} = {}
|
||||
) {
|
||||
|
@ -241,7 +266,7 @@
|
|||
|
||||
console.log('Proxy settings changed.', details);
|
||||
const noCon = 'no-control';
|
||||
const ifWasControllable = handler.ifControllable;
|
||||
const ifWasControllable = handlers.ifControllable;
|
||||
if ( !handlers.isControllable(details) && ifWasControllable ) {
|
||||
handlers.mayNotify(
|
||||
noCon,
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
const Warning = window.apis.errorsLib.Warning;
|
||||
|
||||
const httpLib = window.apis.httpLib;
|
||||
const handlers = window.apis.errorHandlers;
|
||||
|
||||
const asyncLogGroup = function asyncLogGroup(...args) {
|
||||
|
||||
|
@ -65,9 +66,9 @@
|
|||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
chrome.proxy.settings.get({}, timeouted( (details) => {
|
||||
handlers.updateControlState( () => {
|
||||
|
||||
if ( !window.utils.areSettingsControlledFor( details ) ) {
|
||||
if ( !handlers.ifControlled ) {
|
||||
|
||||
console.warn('Failed, other extension is in control.');
|
||||
return cb(
|
||||
|
@ -77,7 +78,8 @@
|
|||
}
|
||||
console.log('Successfuly set PAC in proxy settings..');
|
||||
cb();
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
}));
|
||||
|
||||
|
@ -403,7 +405,9 @@
|
|||
return cb(err);
|
||||
}
|
||||
this.setCurrentPacProviderKey(null);
|
||||
this.pushToStorageAsync(cb);
|
||||
this.pushToStorageAsync(
|
||||
() => handlers.updateControlState(cb)
|
||||
);
|
||||
|
||||
})
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user