Skip to content

Instantly share code, notes, and snippets.



Last active Jul 7, 2017
What would you like to do?
messin with firefox context menu
// 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.addEventListener('popupshowing', () => {
/* if (gContextMenu.linkURL) {
} 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.