GM.registerMenuCommand: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
m (title underscore template)
(link to other docs)
(45 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{underscore|title=GM_registerMenuCommand}}
As of Greasemonkey 4.0, this method has been removed.
 
* See [https://wiki.greasespot.net/index.php?title=GM_registerMenuCommand&oldid=7473 history] for older versions.
= Syntax =
* See the [https://github.com/greasemonkey/gm4-polyfill GM4 Polyfill] for a Greasemonkey 4 compatible way to get similar functionality.
 
'''GM_registerMenuCommand(''' ''commandName'', ''commandFunc'', ''accelKey'', ''accelModifiers'', ''accessKey'' ''')'''
 
= Description =
 
Userscripts can call GM_registerMenuCommand to add a menu command to the "User Script Commands" submenu.
The first two arguments are required; the others are optional.
 
; commandName : Name to display in the menu
; commandFunc : Function to call
; accelKey : A single character (e.g. 'g') or keycode that can trigger the command
; accelModifiers: A string listing modifiers that must be pressed with the accelKey. If there's more than one, then they should be separated with spaces. For example, <code>'shift'</code> or <code>'ctrl alt'</code>. Available modifiers are: shift, alt, meta, control, and accel.
; accessKey : A single character (e.g. 'g') that can be used to jump to the command when the menu is open. It should be a letter in commandName
 
= 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 );

Revision as of 15:22, 14 November 2017

As of Greasemonkey 4.0, this method has been removed.

  • See history for older versions.
  • See the GM4 Polyfill for a Greasemonkey 4 compatible way to get similar functionality.