Dive Into Greasemonkey

Teaching an old web new tricks

6.2. Adding items to the menubar

Greasemonkey defines a function, GM_registerMenuCommand, that allows user scripts to add menu items to the Firefox menu bar. Registered menu items appear in the User Script Commands submenu when the user script is active.

function GM_registerMenuCommand(menuText, callbackFunction);

menuText is a string, the text of the menu item to add. callbackFunction is a function object. When the menu item is selected, the callbackFunction function is called.

This function was introduced in Greasemonkey 0.2.6. You should test whether it exists and degrade gracefully if it does not.

Further reading

← Storing and retrieving persistent data
Integrating data from other sites →