Last active
July 7, 2017 21:33
-
-
Save jaredhirsch/0754718a29a471133dab27e9cdf51cb9 to your computer and use it in GitHub Desktop.
messin with firefox context menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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