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) => void)

      Callback function when the command is clicked in the menu.

        • (event): void
        • Parameters

          • event: MouseEvent | KeyboardEvent

          Returns void

    • Optional options: {
          autoClose?: boolean;
          id?: string;
          title?: string;
      }

      Since

      VM2.15.9

      • Optional autoClose?: boolean

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

      • Optional id?: string

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

      • Optional title?: string

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

    Returns string