From 55f5de2b13ea3844b99b71fa1e2c9db043a97884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Mon, 22 Apr 2024 11:26:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tampermonkey.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tampermonkey.js b/tampermonkey.js index dcb180c8..e88e53cc 100644 --- a/tampermonkey.js +++ b/tampermonkey.js @@ -197,7 +197,7 @@ const options = typeof options_or_accessKey === "string" ? { accessKey: options_or_accessKey } : options_or_accessKey; // 生成菜单ID - let menuCmdId = options.id || ""; + let menuCmdId; if (options.id) { if (options.id.indexOf(MENU_ID_PRE) === 0) { menuCmdId = options.id; @@ -205,7 +205,7 @@ menuCmdId = MENU_ID_PRE + options.id; } } else { - menuCmdId = MENU_ID_PRE + (options.id || ++context.menuIndex); + menuCmdId = MENU_ID_PRE + (++context.menuIndex); } // 创建菜单元素 @@ -239,6 +239,10 @@ }, // 删除菜单 GM_unregisterMenuCommand: (menuCmdId) => { + if (menuCmdId == null) { + return; + } + if (menuCmdId.indexOf(MENU_ID_PRE) !== 0) { menuCmdId = MENU_ID_PRE + menuCmdId; }