GM registerMenuCommand

From GreaseSpot

Jump to: navigation, search
The correct title of this article is GM_registerMenuCommand. The substitution or omission of an _ is due to technical restrictions.



Image:Book.png
Greasemonkey Manual
Using Greasemonkey
Installing Scripts
Manage Dialog
Monkey Menu
User Script Authoring
Editing
Other Useful Tools
Environment
API
User Contributions
Code Snippets


[edit] Description

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

Examples | Notes

[edit] Syntax

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

Value: Function
Returns: undefined
Compatibility: Greasemonkey 0.2.5+
Parameters
Properties Event Handlers
commandName commandFunc
accelKey
accelModifiers
accessKey

top

[edit] Properties


[edit] commandName

Value: String
Usage: commandName = "Some Name";

top | back

[edit] commandFunc

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

top | back

[edit] accelKey

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

top | back

[edit] 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

[edit] 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

[edit] Examples

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


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


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

[edit] Notes

top

Personal tools