如何用addon更改firefox配置

时间:2014-04-11 07:42:13

标签: javascript firefox firefox-addon

我想用我的插件更改用户的firefox配置设置。我该怎么做,我想要更改用户的配置与在同一个标​​签中打开链接有关,该标签会将browser.link.open_newwindow.restriction切换为0。

1 个答案:

答案 0 :(得分:1)

如果是Addon-SDK扩展,请使用以下内容:

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

如果它是无重启或经典(重叠)扩展程序,您可以使用nsIPrefServicensIPrefBranch(通过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);