Skip to content

Menu commands not updating in real time #2220

@PRO-2684

Description

@PRO-2684

Expected Behavior

When I GM_registerMenuCommand and GM_unregisterMenuCommand with autoClose set to false, the menu commands should be updated immediately.

Actual Behavior

The update is not reflected until I re-open the Tampermonkey popup, rendering autoClose useless.

Specifications

  • Chromium: Edge 130.0.2849.56
  • TM: 5.3.6216
  • OS: Windows 23H2

Script

// ==UserScript==
// @name         Test menu commands
// @namespace    http://tampermonkey.net/
// @version      DEBUG
// @description  try to take over the world!
// @author       PRO-2684
// @match        https://www.tampermonkey.net/*
// @icon         http://tampermonkey.net/favicon.ico
// @license      gpl-3.0
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// ==/UserScript==

(function() {
    'use strict';
    let cnt = 0;
    const autoClose = false;
    const id = GM_registerMenuCommand(`Count: ${cnt}`, update, { autoClose });
    function update() {
        cnt++;
        GM_registerMenuCommand(`Count: ${cnt}`, update, { id, autoClose });
    };
    const unregId = GM_registerMenuCommand("Self-Unregister", () => {
        GM_unregisterMenuCommand(unregId);
    }, { autoClose });
})();

In either case, re-opening Tampermonkey popup is required in order to see the updated menu.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions