Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/piroor/fxaddonlib-prefs
Utility to operater preferences database for Firefox/Thunderbird addons
https://github.com/piroor/fxaddonlib-prefs
Last synced: 13 days ago
JSON representation
Utility to operater preferences database for Firefox/Thunderbird addons
- Host: GitHub
- URL: https://github.com/piroor/fxaddonlib-prefs
- Owner: piroor
- License: mit
- Created: 2013-02-19T11:02:33.000Z (over 11 years ago)
- Default Branch: trunk
- Last Pushed: 2020-07-06T16:52:07.000Z (over 4 years ago)
- Last Synced: 2023-03-11T10:42:54.613Z (over 1 year ago)
- Language: JavaScript
- Size: 253 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.ja.txt
Awesome Lists containing this project
README
# Preferences Library, for Firefox older than its version 57.
This project is obsolete and not maintained anymore.
## Usage
Developer-friendly utility (for bootstrapped extensions):
// you can create a new "store" which is bound to specific base key (domain).
var store = window['piro.sakura.ne.jp'].prefs.createStore('extensions.someextension');
// you can define new preference under the base key.
store.define('enabled' /* property name and key */,
true /* default value */);
// then it will be defined as: extensions.someextension.enabled=true
// and you can read the value as a static property like:
var enabled = store.enabled;
// the value will be updated automatically when the user change the preference.
// if you want to define the preference with a key different to the property name...
store.define('leftMargin', true, 'margin.left' /* the actual key */);
// after all, free the memory.
store.destroy();Low level APIs (for legacy type addons):
var value = window['piro.sakura.ne.jp'].prefs.getPref('my.extension.pref');
window['piro.sakura.ne.jp'].prefs.setPref('my.extension.pref', true);
window['piro.sakura.ne.jp'].prefs.clearPref('my.extension.pref');
var listener = {
domains : [
'browser.tabs',
'extensions.someextension'
],
observe : function(aSubject, aTopic, aData)
{
if (aTopic != 'nsPref:changed') return;
var value = window['piro.sakura.ne.jp'].prefs.getPref(aData);
}
};
window['piro.sakura.ne.jp'].prefs.addPrefListener(listener);
window['piro.sakura.ne.jp'].prefs.removePrefListener(listener);