Function GM_registerMenuCommand

  • Registers a command in Violentmonkey popup menu. Returns the command's id since VM2.12.5, see description of the id parameter. If you want to add a shortcut, please see @violentmonkey/shortcut.

    Parameters

    • caption: string

      The name to show in the popup menu.

    • onClick: (event: MouseEvent | KeyboardEvent) => void

      Callback function when the command is clicked in the menu.

    • Optionaloptions: { autoClose?: boolean; id?: string; title?: string }

      VM2.15.9

      • OptionalautoClose?: boolean

        Default: true. Whether to auto-close the popup after the user invoked the command.

      • Optionalid?: string

        Default: the caption parameter. In 2.15.9-2.16.1 the default was a randomly generated string.

      • Optionaltitle?: string

        A hint shown in the status bar when hovering the command.

    Returns string