我想制作firefox插件,将默认的新页面和起始页面更改为特定页面。我尝试使用复选框来启用或禁用设置的“选项”窗口,但它们无法正常工作。请帮帮我。
preferences.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="mystartpage-options" label="Opcje">
<preferences>
<preference id="extensions.mystartpage.overrideHomePage" name="extensions.mystartpage.overrideHomePage" type="bool"/>
<preference id="extensions.mystartpage.overrideNewTab" name="extensions.mystartpage.overrideNewTab" type="bool"/>
</preferences>
<checkbox id="useAsHomePage" label="Strona startowa" preference="extensions.mystartpage.overrideHomePage"/>
<checkbox id="openInNewTabs" label="Nowa karta" preference="extensions.mystartpage.overrideNewTab"/>
</prefpane>
<script type="application/x-javascript" src="preferences.js"/>
</prefwindow>
preferences.js:
mystartpageoptions = new function () {
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("accessibility.");
Components.utils.import("resource://gre/modules/Services.jsm");
if ((Services.prefs.getBoolPref("extensions.mystartpage.overrideNewTab")) = true)
Services.prefs.setCharPref("browser.newtab.url", "chrome://mystartpage/content/index.html")
else Services.prefs.clearUserPref("browser.newtab.url");
if ((Services.prefs.getBoolPref("extensions.mystartpage.overrideHomePage")) = true)
Services.prefs.setCharPref("browser.startup.homepage", "chrome://mystartpage/content/index.html")
else Services.prefs.clearUserPref("browser.startup.homepage");
}