Persist state between relaunches for Firefox

This commit is contained in:
Ilya Ig. Petrov 2017-11-22 16:03:20 +05:00
parent a35ab098d4
commit 4738bcf9af
2 changed files with 10 additions and 13 deletions

View File

@ -256,11 +256,13 @@
if (!chrome.proxy.settings) {
let currentSettings = {};
const ffxStore = window.utils.createStorage('firefox-only');
chrome.proxy.settings = {
get: (_, cb) => {
let currentSettings = ffxStore('proxySettings') || {};
currentSettings.levelOfControl = 'controlled_by_this_extension'; // May be lie, but this field is required.
cb(currentSettings);
@ -274,14 +276,19 @@
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});
currentSettings = details;
ffxStore('proxySettings', details);
cb();
},
};
const proxySettings = ffxStore('proxySettings');
if (proxySettings) {
chrome.proxy.settings.set(proxySettings);
}
}
}

View File

@ -242,12 +242,6 @@
},
clearLastModified() {
this.setLastModified(0);
},
mustBeKey(key = mandatory()) {
if ( !(key === null || this.pacProviders[key]) ) {
@ -525,10 +519,6 @@
// LAUNCH, RELOAD, ENABLE
antiCensorRu.pacProviders = oldStorage.pacProviders;
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();
}