handling firefox extension prefrences across sessions
I'm working on a firefox extention. I like to give s开发者_StackOverflow中文版ome options for the user, like setting background
color and others. I need to retrive these options for each tabs. Where should i can store the values?how can i get around this issue?
You can use the XPCOM interfaces to Firefox' preferences system:
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("extensions.yourextension.");
prefs.setIntPref("yourPersistedValue", 42);
See this article for more information and code samples.
Alternatively, you can use SQLite. See this answer for details.
精彩评论