A Firefox extension that changes a value in the about:config
Asked Answered
A

2

11

I've been searching far and wide through 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.

Atomic answered 27/5, 2011 at 20:4 Comment(0)
B
8

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

Byrle answered 27/5, 2011 at 20:48 Comment(5)
Thanks! Your answer helped me, but after much reading, what I did was modify an existing addon (a bootstrap) with a similar funtionality: addons.mozilla.org/en-US/firefox/addon/browse-by-nameAtomic
Is it not a security whole that a extension can edit any about:config setting not belonging to itself at all?Macfarlane
@Atomic could you please name the extension. I need to do similar thing. An add on that changes some values in the about:configNoami
@Macfarlane I'm not sure, but I can't think of a specific security problem. It can change Firefox's behaviour in many ways, but that's what you expect to happen when installing an extension.Boyhood
So, How to do it in Firefox 57?Anglophobia
L
0

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!

Leucocratic answered 20/11, 2014 at 0:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.