Skip to content

Instantly share code, notes, and snippets.

@jeffgca
Last active December 28, 2015 20:39
Show Gist options
  • Save jeffgca/7559147 to your computer and use it in GitHub Desktop.
Save jeffgca/7559147 to your computer and use it in GitHub Desktop.
Add a menu to Fennec's tools menu (?) - now with a full working example.
const utils = require('sdk/window/utils');
const recent = utils.getMostRecentBrowserWindow();
// Assume NativeWindow is a global
function showToast() {
recent.NativeWindow.toast.show("Showing you a toast", "short");
}
var menuID;
function addMenuItem() {
menuID = recent.NativeWindow.menu.add({
name: "Show Toast",
icon: null,
parent: recent.NativeWindow.menu.toolsMenuID,
callback: function() {
showToast();
}
});
}
function removeMenuItem() {
recent.NativeWindow.menu.remove(menuID);
}
addMenuItem();
exports.onUnload = function() {
removeMenuItem();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment