mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-12-17 21:46:18 +03:00
Persist state between relaunches for Firefox
This commit is contained in:
parent
a35ab098d4
commit
4738bcf9af
|
@ -256,11 +256,13 @@
|
||||||
|
|
||||||
if (!chrome.proxy.settings) {
|
if (!chrome.proxy.settings) {
|
||||||
|
|
||||||
let currentSettings = {};
|
const ffxStore = window.utils.createStorage('firefox-only');
|
||||||
|
|
||||||
|
|
||||||
chrome.proxy.settings = {
|
chrome.proxy.settings = {
|
||||||
get: (_, cb) => {
|
get: (_, cb) => {
|
||||||
|
|
||||||
|
let currentSettings = ffxStore('proxySettings') || {};
|
||||||
currentSettings.levelOfControl = 'controlled_by_this_extension'; // May be lie, but this field is required.
|
currentSettings.levelOfControl = 'controlled_by_this_extension'; // May be lie, but this field is required.
|
||||||
cb(currentSettings);
|
cb(currentSettings);
|
||||||
|
|
||||||
|
@ -274,14 +276,19 @@
|
||||||
browser.proxy.register('./default.pac.js');
|
browser.proxy.register('./default.pac.js');
|
||||||
|
|
||||||
|
|
||||||
browser.proxy.onProxyError.addListener((...err) => { console.log('ERROR IN PAC:', ...err) });
|
// browser.proxy.onProxyError.addListener((...err) => { console.log('ERROR IN PAC:', ...err) });
|
||||||
|
|
||||||
browser.runtime.sendMessage(details, {toProxyScript: true});
|
browser.runtime.sendMessage(details, {toProxyScript: true});
|
||||||
currentSettings = details;
|
ffxStore('proxySettings', details);
|
||||||
cb();
|
cb();
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
const proxySettings = ffxStore('proxySettings');
|
||||||
|
if (proxySettings) {
|
||||||
|
chrome.proxy.settings.set(proxySettings);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,12 +242,6 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
clearLastModified() {
|
|
||||||
|
|
||||||
this.setLastModified(0);
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
mustBeKey(key = mandatory()) {
|
mustBeKey(key = mandatory()) {
|
||||||
|
|
||||||
if ( !(key === null || this.pacProviders[key]) ) {
|
if ( !(key === null || this.pacProviders[key]) ) {
|
||||||
|
@ -525,10 +519,6 @@
|
||||||
// LAUNCH, RELOAD, ENABLE
|
// LAUNCH, RELOAD, ENABLE
|
||||||
antiCensorRu.pacProviders = oldStorage.pacProviders;
|
antiCensorRu.pacProviders = oldStorage.pacProviders;
|
||||||
console.log('Extension launched, reloaded or enabled.');
|
console.log('Extension launched, reloaded or enabled.');
|
||||||
if (window.apis.platform.ifFirefox) {
|
|
||||||
antiCensorRu.clearLastModified();
|
|
||||||
await new Promise((r) => antiCensorRu.syncWithPacProviderAsync(r)); // On each launch, ffx has no memory.
|
|
||||||
}
|
|
||||||
return resolve();
|
return resolve();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user