Listing 2. contextmenu.js var picnikContextMenu = { onLoad:function() { // Attach the showContextMenu function // to the context menu var e = document.getElementById("contentAreaContextMenu") if( e ) e.addEventListener("popupshowing", function(ev){ picnikContextMenu.showContextMenu(ev); }, false); }, // Called right before the context menu // popup is shown showContextMenu: function(event) { if( gContextMenu ) { var edit_picture = document.getElementById("picnik-ctx-edit"); if( edit_picture ) edit_picture.hidden = ! (gContextMenu.onImage || gContextMenu.hasBGImage); if( gContextMenu.onImage ) this.imageURL = gContextMenu.imageURL; else if( gContextMenu.hasBGImage ) this.imageURL = gContextMenu.bgImageURL; else this.imageURL = ''; } }, // Called if the user clicks the 'edit' // menu item editImage: function() { var url = picnikCommon.baseURL + "?import=" + escape(this.imageURL); gBrowser.selectedTab = gBrowser.addTab(url); }, }; window.addEventListener("load", picnikContextMenu.onLoad, false);