This commit is contained in:
parent
92560e1172
commit
e85d37ff7c
6 changed files with 41 additions and 24 deletions
65
bootstrap.js
vendored
65
bootstrap.js
vendored
|
@ -130,41 +130,58 @@ async function install() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
async function uninstall(aData, aReason) {
|
async function uninstall({resourceURI}, aReason) {
|
||||||
if (aReason === ADDON_UNINSTALL
|
if (checkLegacyFirefox()) {
|
||||||
|| aReason === ADDON_DISABLE) {
|
if (aReason === ADDON_UNINSTALL) {
|
||||||
const config = await getConfig();
|
unloadStyles(resourceURI);
|
||||||
const storedPrefs = config.savedConfiguration.prefs || {};
|
await removeChanges();
|
||||||
PREFS.forEach((pref) => {
|
}
|
||||||
let value = pref.default;
|
|
||||||
if (pref.name in storedPrefs) {
|
|
||||||
value = storedPrefs[pref.name];
|
|
||||||
}
|
|
||||||
if ("int" === pref.type) {
|
|
||||||
Services.prefs.setIntPref(pref.name, value);
|
|
||||||
} else {
|
|
||||||
Services.prefs.setBoolPref(pref.name, value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function removeChanges() {
|
||||||
|
const config = await getConfig();
|
||||||
|
const storedPrefs = config.savedConfiguration.prefs || {};
|
||||||
|
PREFS.forEach((pref) => {
|
||||||
|
let value = pref.default;
|
||||||
|
if (pref.name in storedPrefs) {
|
||||||
|
value = storedPrefs[pref.name];
|
||||||
|
}
|
||||||
|
if ("int" === pref.type) {
|
||||||
|
Services.prefs.setIntPref(pref.name, value);
|
||||||
|
} else {
|
||||||
|
Services.prefs.setBoolPref(pref.name, value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkLegacyFirefox() {
|
||||||
|
const version = Services.appinfo.version;
|
||||||
|
const versionMatch = version.match(/^([0-9]+)\./)[1];
|
||||||
|
if (Number(versionMatch) <= 56) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
function startup({webExtension, resourceURI}) {
|
function startup({webExtension, resourceURI}) {
|
||||||
const version = Services.appinfo.version;
|
if (checkLegacyFirefox()) {
|
||||||
const versionMatch = version.match(/^([0-9]+)\./)[1];
|
|
||||||
if (versionMatch === "55"
|
|
||||||
|| versionMatch === "56") {
|
|
||||||
loadStyles(resourceURI);
|
loadStyles(resourceURI);
|
||||||
|
// Reset prefs that may have changed, or are legacy
|
||||||
|
install();
|
||||||
}
|
}
|
||||||
// Reset prefs that may have changed, or are legacy
|
|
||||||
install();
|
|
||||||
// Start the embedded webextension.
|
// Start the embedded webextension.
|
||||||
webExtension.startup();
|
webExtension.startup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
function shutdown({resourceURI}) {
|
function shutdown({resourceURI}, aReason) {
|
||||||
unloadStyles(resourceURI);
|
if (checkLegacyFirefox()) {
|
||||||
|
unloadStyles(resourceURI);
|
||||||
|
if (aReason === ADDON_DISABLE) {
|
||||||
|
removeChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
webextension/web-ext-artifacts/mozilla_containers-3.1.1.zip
Normal file
BIN
webextension/web-ext-artifacts/mozilla_containers-3.1.1.zip
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue