Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

GM_registerMenuCommand

erikvold edited this page · 8 revisions

Description

GM_registerMenuCommand allows a user script to add a menu item to Scriptish's menu which calls a function when clicked.

Note: No menu command is created when the user script is run in a iframe window.

Arguments

String caption

A caption for the menu item.

Function commandFunc

The function executed when this menu item is clicked.

String accelKey

A single character or key code that can trigger the command.

String accelModifiers

A string listing modifiers which must be pressed with the accelKey. If there is more than one, then they should be separated with spaces. Available modifiers are: shift, alt, meta, control, and accel.

String accessKey

A single character that can be used to jump to the command when the menu is open. It should be a letter in the caption.

Returns (new in Scriptish!)

String uuid

The UUID (universally unique identifier) of the new menu command. This UUID can be used with GM_unregisterMenuCommand, GM_enableMenuCommand, and GM_disableMenuCommand.

Examples

function sayHello() { alert("Hello, world!"); }
GM_registerMenuCommand("Hello, world (simple)", sayHello);
function sayHello() { alert("Hello, world!"); }
GM_registerMenuCommand("Hello, world!", sayHello, "e", "control", "h");
function sayHello() { alert("Hello, world!"); }
GM_registerMenuCommand("Hello, world! (again)", sayHello, "e", "shift alt", "w");

Related Pages

Manual: API

Something went wrong with that request. Please try again.