I've been searching far and wide thr开发者_如何学运维ough the web for some tiny bit of light, but found nothing. I need to create a Firefox extension that, among a few other things, changes the value of one of the about:config variables. None of the tutorials I've found covers that issue, so I don't know where to start. Can anyone throw me a link, or some lines of code or explanation, just to help me get started? Thanks in advance.
Firefox 57 and newer (WebExtensions)
Not possible, details in Is it possible to create a Firefox WebExtension that changes about:config settings? How?
Old Firefox (legacy extensions)
The about:config values are accessed via the preferences system. The reason you preface your extension's prefs with extensions.myextension is because you need to make sure you don't collide with Firefox's or another extension's preferences.
To get a firefox preference just use the same preference name as you see in about:config. If you notice, you'll see that you also see all of the extension prefs in about:config too.
https://developer.mozilla.org/en/XUL_School/Handling_Preferences * https://developer.mozilla.org/en/Code_snippets/Preferences
If you are using bootstrap, this should do what you're looking for:
prefs = require("sdk/preferences/service");
prefs.set("extensions." + extensionName + ".sdk.console.logLevel", "all");
It might not be the most elegant solution - but you can comment out the code before you publish.
If anyone finds a better way, please let me know!
精彩评论