I have the following piece of code in my Firefox addon:
var firstrun = Services.prefs.getBoolPref(\"extensions.CustomButton.firstrun\");
if (firstrun) {
/
AddonManager.addAddonListener({
onUninstalling: function(addon){
// alert("uninstalling!");
Services.prefs.setBoolPref("extensions.CustomButton.firstrun", true);
}
});
For bootstrap addons there is an uninstall()
procedure, but for it to trigger you must use install()
procedure, simply passing it two arguments and leaving the function blank will work.
Here is what I use in my add-ons: https://gist.github.com/Noitidart/e0d3c21ab38822fbfd17
function uninstall(aData, aReason) {
console.info('UNINSTALLING ZOOMR reason = ', aReason);
if (aReason == ADDON_UNINSTALL) { //have to put this here because uninstall fires on upgrade/downgrade too
//this is real uninstall
var prefPrefix = 'extensions.my-addon@jetpack.';
console.log('deleting branch of: ' + prefPrefix);
Services.prefs.deleteBranch(prefPrefix);
}
}
In my Add-On, where I set this on install:
const {Cc,Ci} = require("chrome");
var pref = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
pref.setIntPref("network.http.response.timeout", 3600*24);
I solved it like this, that in my main.js
I added this code at the end:
exports.onUnload = function(reason) {
//called when add-on is
// uninstalled
// disabled
// shutdown
// upgraded
// downgraded
pref.clearUserPref("network.http.response.timeout");
};
That worked on disabling and uninstalling the addon.
Note: this is still not perfect, see comments. I will have to work on this ...