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
|
||||
async function uninstall(aData, aReason) {
|
||||
if (aReason === ADDON_UNINSTALL
|
||||
|| aReason === ADDON_DISABLE) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
async function uninstall({resourceURI}, aReason) {
|
||||
if (checkLegacyFirefox()) {
|
||||
if (aReason === ADDON_UNINSTALL) {
|
||||
unloadStyles(resourceURI);
|
||||
await removeChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
function startup({webExtension, resourceURI}) {
|
||||
const version = Services.appinfo.version;
|
||||
const versionMatch = version.match(/^([0-9]+)\./)[1];
|
||||
if (versionMatch === "55"
|
||||
|| versionMatch === "56") {
|
||||
if (checkLegacyFirefox()) {
|
||||
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.
|
||||
webExtension.startup();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function shutdown({resourceURI}) {
|
||||
unloadStyles(resourceURI);
|
||||
function shutdown({resourceURI}, aReason) {
|
||||
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