因為自己在寫 UserChrome.js ,
所以需要常常重新啟動火狐狸。
也因此寫了一小段程式用來重開火狐狸。
最主要的是參考網路上的原始碼來重新開啟火狐狸,
其他部份就跟一般的 UserChrome.js 。
這是讓你按右鍵的選單裡有 Restart! 可以使用。
function ucjsRestartApp() {
var appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
.getService(Ci.nsIAppStartup);
appStartup.quit(appStartup.eRestart | appStartup.eAttemptQuit);
}
(function() {
var newItem = document.createElement("menuitem");
newItem.setAttribute("label", "ReStart!");
newItem.setAttribute("oncommand", "ucjsRestartApp();");
var m = document.getElementById("userChrome-Menu");
if (!m) {
var openLink = document.getElementById("context-openlink");
m = document.createElement("menu");
m.setAttribute("id", "userChrome-Menu");
m.setAttribute("label", "userChrome");
openLink.parentNode.appendChild(m);
}
var mpopup = document.getElementById("userChrome-MenuPopup");
if (!mpopup) {
mpopup = document.createElement("menupopup");
mpopup.setAttribute("id", "userChrome-MenuPopup");
m.appendChild(mpopup);
}
mpopup.appendChild(newItem);
})();