Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GM_registerMenuCommand not trigger click callback in firefox browser #2005

Open
WhiteSevs opened this issue Mar 18, 2024 · 0 comments
Open
Milestone

Comments

@WhiteSevs
Copy link

WhiteSevs commented Mar 18, 2024

Expected Behavior

期望修复注册顺序和点击回调无效的问题

Actual Behavior

注册菜单 => test1->test2->test3

卸载菜单

注册菜单 => test2->test3->test1

问题:在最后注册完菜单完成后,菜单顺序不同,且菜单test2test3的点击事件不触发,只有test1的点击事件触发
该测试在Edge+TamperMonkey BETA 5.1.6193下又是正常的

Specifications

  • Firefox: 123.0.1
  • TM: 5.1.6193
  • OS: Win 10

Script

// ==UserScript==
// @name            Debug GM_registerMenuCommand
// @version         0.1
// @author          WhiteSevs
// @match           *://*/*
// @run-at          document-start
// @grant           GM_registerMenuCommand
// @grant           GM_unregisterMenuCommand
// ==/UserScript==

(function () {
  const menuIdMap = {};
  const menuList = [
    {
      text: "test1",
      callback(event) {
        console.log(`test1 click`, event);
      },
    },
    {
      text: "test2",
      callback(event) {
        console.log(`test2 click`, event);
      },
    },
    {
      text: "test3",
      callback(event) {
        console.log(`test3 click`, event);
      },
    },
  ];
  function register() {
    menuList.forEach((item) => {
      let menuId = GM_registerMenuCommand(item.text, item.callback);
      menuIdMap[menuId] = item;
    });
  }
  function unRegister() {
    for (const key in menuIdMap) {
      GM_unregisterMenuCommand(key);
    }
  }
  register();
  unRegister();
  register();
})();
@derjanb derjanb added this to the 5.2 milestone Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants