Dive Into Greasemonkey

Teaching an old web new tricks


GM_registerMenuCommand — add a menu item to the User Script Commands submenu


function GM_registerMenuCommand(   menuText,


GM_registerMenuCommand adds a menu item to the ToolsUser Script Commands menu. The menuText argument is a string, the text of the menu item to add. The callbackFunction argument is a function object. When the menu item is selected, the callbackFunction function is called.

function callbackFunction(e);

The e parameter is the menu selection event. I'm not sure if this is useful for anything.


There is no way to set a menu accelerator key. Calling GM_registerMenuCommand('Some &menu text', myFunction) will create a menu item titled “Some &menu text”. (Bug 10090)


GM_registerMenuCommand was introduced in Greasemonkey 0.2.6.

← GM_setValue
GM_xmlhttpRequest →