Firefox Add-On Development - Add Item to Right Click on Tab

I had an idea for an add on that would require me to add an item/menu-item to a tab when someone right clicks on it. How would I implement this? I have no Firefox Add-On experience and I just had an idea that is simple, yet I thought would be cool.

Answers


Use window.document.getElementById("tabContextMenu") to manipulate tab's menu.

Here is code of New Tab in Tab Context Menu

let _ = require("l10n").get;
let winUtils = require("window-utils");
let { isBrowser } = require("api-utils/window/utils");
var delegate = {
    onTrack: function (window) {
        if (isBrowser(window) ){
          let menu = window.document.getElementById("tabContextMenu");
          let newtab = window.document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul","menuitem");
          newtab.setAttribute("id", "contexttab-newtab");
          newtab.setAttribute("label", _("newtab_string"));
          newtab.setAttribute("accesskey", _("newtabaccesskey_string"));
          newtab.setAttribute("oncommand", "BrowserOpenTab();");
          menu.insertBefore(newtab, menu.firstChild);
       } // End isBrowser
    }  // End ontrack
} // End delegate function

let tracker = new winUtils.WindowTracker(delegate);

Need Your Help

Sorting names entered by the user in alphabetical order according to the last name

java sorting indexoutofboundsexception selection-sort

I have completed most of the code by myself (with the help of a bit of Googling) but I have run into an unexpected problem. First-off, I have to sort a user entered list of names in aplhabetical or...