How to use and access the preference in thunderbird , in Webextension environment ,not in the legacy

413 Views Asked by At

Currently using this method as a legacy method.

this.prefService = Components
       .classes["@mozilla.org/preferences-service;1"]
       .getService(Components.interfaces.nsIPrefService);

 this.prefBranch = this.prefService.getBranch(root);

but i did not get a complete idea about how to use this in the webextension environment thunderbird .any api in order to use this feature ?

2

There are 2 best solutions below

0
On BEST ANSWER

I solved my issue, by using Web Extension experiment.

Implemented the same legacy extension function with the Web Extension Experiment Specification and that solved my need at this moment. the link mentioned below.

https://thunderbird-webextensions.readthedocs.io/en/68/how-to/experiments.html

https://firefox-source-docs.mozilla.org/toolkit/components/extensions/webextensions/functions.html

0
On

I think you can use the storage.local API (see documentation, it seems to work the same for Firefox and Thunderbird). This allows you to store data related to your add-on with something like:

let settingItem = browser.storage.local.set(
  keys             // object
)

and to retrieve or remove it after that (see available methods).