map-making.app hide UI

Press `h` to hide the UI

  1. // ==UserScript==
  2. // @name map-making.app hide UI
  3. // @namespace alienperfect
  4. // @match https://map-making.app/*
  5. // @grant GM_addStyle
  6. // @version 1.1
  7. // @author Alien Perfect
  8. // @description Press `h` to hide the UI
  9. // ==/UserScript==
  10.  
  11. "use strict";
  12.  
  13. const key = "h";
  14. let style;
  15. let hidden;
  16.  
  17. document.addEventListener("keydown", (e) => {
  18. if (e.key === key && document.activeElement.tagName !== "INPUT" && !hidden) return hide();
  19. if (e.key === key && hidden) return show();
  20. });
  21.  
  22. function hide() {
  23. style = GM_addStyle(`
  24. .embed-controls {display: none !important}
  25. .SLHIdE-sv-links-control {display: none !important}
  26. [class$="gmnoprint"], [class$="gm-style-cc"] {display: none !important}
  27. `);
  28.  
  29. hidden = true;
  30. }
  31.  
  32. function show() {
  33. style.remove();
  34. hidden = false;
  35. }