GM.registerMenuCommand

From GreaseSpot Wiki
Revision as of 23:28, 6 December 2007 by Marti (talk | contribs) (Symmetry update (Hope everyone likes it :))
Jump to navigationJump to search

Template:Underscore


Description

This API method allows user scripts to add a menu command to the "User Script Commands" submenu.

Examples | Notes

Syntax

GM_registerMenuCommand( commandName, commandFunc, accelKey, accelModifiers, accessKey )

Returns: Nothing, details Object
Compatibility: Greasemonkey 0.2.5+
Parameters
Properties Event Handlers
commandName commandFunc
accelKey
accelModifiers
accessKey

top

Properties


commandName

Value: String
Usage: commandName

top | back

commandFunc

Value: String
Usage: commandFunc = function(){ // Some code };
  • Function to call

top | back

accelKey

Value: Object
Usage: accelKey = "g";
  • A single character or keycode that can trigger the command.

top | back

accelModifiers

Value: String
Usage: accelModifiers = "control alt";
  • A string listing modifiers that must be pressed with the accelKey. If there's more than one, then they should be separated with spaces. Available modifiers are: shift, alt, meta, control, and accel.

top | back

accessKey

Value: String
Usage: accessKey = "g";
  • A single character that can be used to jump to the command when the menu is open. It should be a letter in commandName.

top | back

Examples

GM_registerMenuCommand( "Hello, world!", hello, "e", "control", "h" );

GM_registerMenuCommand( "Hello, world! (again)", hello2, "e", "shift alt", "w" );

GM_registerMenuCommand( "Hello, world (simple)", helloSimple );

top

Notes

top