Moonbounce Focus Keybind

Allows you to use the "=" key to toggle focus. ((made with <3 by lune))

  1. // ==UserScript==
  2. // @name Moonbounce Focus Keybind
  3. // @namespace https://github.com/diary001/moonbounce
  4. // @supportURL https://discord.gg/pixel
  5. // @license MIT
  6. // @version 1.0.3
  7. // @description Allows you to use the "=" key to toggle focus. ((made with <3 by lune))
  8. // @author lune / linktr.ee/moon
  9. // @match *://*/*
  10. // @icon https://framerusercontent.com/images/iuVZmsE2sifPExZXNrETQrDkU.png
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. const simulateClick = new MouseEvent('click', {
  18. bubbles: true,
  19. cancelable: true,
  20. view: window
  21. });
  22.  
  23. function toggleFocus() {
  24. const focusContainer = document.querySelector("div#moonbounce-ext-container-mbheeaapbjpckahhciogfdodofjjldem");
  25. if (focusContainer) {
  26. const focusButton1 = focusContainer.shadowRoot.querySelector("#MOONBOUNCE\\.PORTAL > div:nth-child(4) > div > div > div > div._base_1b9zj_1._show_1b9zj_26 > button") || focusContainer.shadowRoot.querySelector("#MOONBOUNCE\\.PORTAL > div:nth-child(2) > div > div > div > div._base_1b9zj_1._show_1b9zj_26 > button");
  27. const focusButton2 = focusContainer.shadowRoot.querySelector("#MOONBOUNCE\\.PORTAL > div:nth-child(4) > div > div > div > div._base_1b9zj_1._hide_1b9zj_30 > button") || focusContainer.shadowRoot.querySelector("#MOONBOUNCE\\.PORTAL > div:nth-child(2) > div > div > div > div._base_1b9zj_1._hide_1b9zj_30 > button");
  28. const focusButton = focusButton1 || focusButton2;
  29. if (focusButton) {
  30. focusButton.dispatchEvent(simulateClick);
  31. }
  32. }
  33. }
  34.  
  35. document.addEventListener('keydown', function(event) {
  36. if (event.key === '=') {
  37. toggleFocus();
  38. }
  39. });
  40. })();