Skip to content

Instantly share code, notes, and snippets.

@6a68

6a68/foo.js

Last active Jul 7, 2017
Embed
What would you like to do?
messin with firefox context menu
Cu.import('resource://gre/modules/Console.jsm');
// get a pointer to the context menu
// TODO: seems to be per-window. how to iterate and attach to all windows? :-(
menu = document.getElementById("contentAreaContextMenu");
// create a hidden menu item
xuldoc = menu.ownerDocument;
item = xuldoc.createElement('menuitem');
item.setAttribute('id', 'minvid-item');
item.setAttribute('label', 'console.log selected URL');
// TODO: wait on toggling visibility for now
// item.setAttribute('hidden', true);
item.setAttribute('oncommand', () => {
console.log('the link URL is: ', gContextMenu.linkURL);
});
// append the item
menu.appendChild(item);
menu.addEventListener('popupshowing', () => {
/* if (gContextMenu.linkURL) {
item.removeAttribute('hidden');
} else {
item.setAttribute('hidden', true);
}
*/
// TODO: doesn't work...
console.log('gContextMenu.linkURL is: ', gContextMenu.linkURL);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.