extension more user-friendly.
const MY_EXT_PREF_BRANCH = "extensions.myext";
const Cc = Components.classes;
const Ci = Components.interfaces;
var myExt = {
PREF_FIRSTRUN : MY_EXT_PREF_BRANCH + ".firstrun",
PAGE_WELCOME : "http://www.myext.com/welcome",
prefService : Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch),
load : function () {
if (myExt.isFirstRun()) {
setTimeout(myExt.openSuccessPage, 2000);
myExt.prefService.setBoolPref(myExt.PREF_FIRSTRUN, false);
}
}
isFirstRun : function() {
return myExt.getBoolPref(myExt.PREF_FIRSTRUN, true);
},
openSuccessPage : function() {
gBrowser.selectedTab = gBrowser.addTab(myExt.PAGE_WELCOME);
},
getBoolPref: function(prefname, prefdef) {
try {
return myExt.prefService.getBoolPref(prefname);
} catch(e) {
myExt.prefService.setBoolPref(prefname, prefdef);
return myExt.prefService.getBoolPref(prefname);
}
}
}
window.addEventListener("load", myExt.load, false);