卡饭上有人求这个功能,我花了5分钟写了个 UC 脚本

location.href.startsWith('chrome://browser/content/browser.x') && setTimeout(() => {
    eval('BookmarksEventHandler.onMouseUp = ' + BookmarksEventHandler.onMouseUp.toString().replace("onMouseUp(aEvent)", "function onMouseUp(aEvent)").replace('aEvent.button == 1', 'aEvent.button == 0 || aEvent.button == 1'));
}, 1000);

新版本不能用 eval 了

(() => {
  if (!location.href.startsWith("chrome://browser/content/browser.x")) {
    return;
  }

  const handler = window.BookmarksEventHandler;
  if (!handler || handler.__leftClickPatchApplied) {
    return;
  }

  handler.onMouseUp = function (aEvent) {
    if (aEvent.button !== 0) {
      return;
    }
    
    const target = aEvent.originalTarget;
    if (target?.tagName !== "menuitem") {
      return;
    }

    const modifKey =
      AppConstants.platform === "macosx"
        ? aEvent.metaKey
        : aEvent.ctrlKey;

    // 普通左键也保持菜单打开
    if (modifKey || aEvent.button === 0 || aEvent.button === 1) {
      target.setAttribute("closemenu", "none");

      const menupopup = target.parentNode;
      menupopup.addEventListener(
        "popuphidden",
        () => target.removeAttribute("closemenu"),
        { once: true }
      );
    } else {
      target.removeAttribute("closemenu");
    }
  };

  Object.defineProperty(handler, "__leftClickPatchApplied", {
    value: true,
  });
})();