Advertisement
Guest User

Untitled

a guest
Oct 5th, 2023
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.75 KB | Source Code | 0 0
  1. // ==UserScript==
  2. // @name           close-the-menu-bar-with-one-esc-keystroke.uc.js
  3. // @version        1
  4. // @description    Escキー1回でメニューバーとメニューの両方を閉じる。
  5. // @include        chrome://browser/content/browser.xhtml
  6. // ==/UserScript==
  7.  
  8. (function () {
  9.   "use strict";
  10.  
  11.   const menubar = document.getElementById("main-menubar");
  12.  
  13.   menubar.addEventListener("popuphidden", (event) => {
  14.     setTimeout(function () {
  15.       if (!menubar.querySelector("menu[open]")) {
  16.         menubar.dispatchEvent(
  17.           new KeyboardEvent("keydown", {
  18.             altKey: true,
  19.             code: "AltRight",
  20.             key: "Alt",
  21.             keyCode: 18,
  22.           }),
  23.         );
  24.       }
  25.     }, 0);
  26.   });
  27. })();
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement