raju
raju

Reputation: 4978

How to change firefox config with addon

I want to change the user's firefox config settings with my addon. How do I do it and the config I want to change of my user's is related to opening link in same tab which would be switching browser.link.open_newwindow.restriction to 0.

Upvotes: 0

Views: 162

Answers (1)

M.J. Saedy
M.J. Saedy

Reputation: 336

If it is an Addon-SDK extension use something like this:

var name = "browser.link.open_newwindow.restriction";
require("sdk/preferences/service").set(name, 0);

If it's a restartless or classic (overlay) extension you can use nsIPrefService and nsIPrefBranch (via Services.jsm)

var {classes:Cc, interfaces:Ci, utils:Cu, results:Cr, Constructor:CC} = Components;
const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
var branch = Services.prefs.getBranch("browser.link.open_newwindow.");
branch.setIntPref('restriction', 0);

Upvotes: 1

Related Questions