问题
My XUL-based Firefox extension stores data in preferences. Is there a way to access this data once when migrating to a WebExtension version?
I am aware of https://wiki.mozilla.org/WebExtensions/FAQ#Does_the_WebExtensions_API_provide_access_to_preferences.3F but hope there is a solution for this specific use-case.
回答1:
Depending on the number of preferences, there are a few options:
- discard them and let your users set them again after upgrading
- read them using an external program which communicates with your webextension, see https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging
- make an export tool (external program) which exports to JSON (or something similar) and make an import option in your webextension
Aside from the options above, it was possible to have a hybrid webextension which could read the preferences and publish it on addons.mozilla.org, but that option expired as of Firefox 57 if I am not mistaken.
来源:https://stackoverflow.com/questions/48650400/access-old-style-firefox-extensions-preferences-when-porting-to-webextensions