Skip to content

Utility to operater preferences database for Firefox/Thunderbird addons

License

Notifications You must be signed in to change notification settings

piroor/fxaddonlib-prefs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

Utility to operater preferences database for Firefox/Thunderbird addons

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published