Moonbounce Dyslexia Theme

Makes the Moonbounce extension components dyslexia friendly

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Moonbounce Dyslexia Theme
// @namespace    https://github.com/diary001/lunebounce
// @supportURL   https://discord.gg/pixel
// @license      MIT
// @version      1.0.1
// @description  Makes the Moonbounce extension components dyslexia friendly
// @author       lune / linktr.ee/moon
// @match        *://*/*
// @icon         https://framerusercontent.com/images/iuVZmsE2sifPExZXNrETQrDkU.png
// @grant        none
// ==/UserScript==
(function () {
    "use strict";

    const docStyle = document.createElement('style');
    docStyle.textContent = `
        @font-face {
          font-family: 'OpenDyslexic';
          src: url('https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Regular.woff') format('woff');
          font-weight: normal;
          font-style: normal;
          font-display: swap;
        }
    `;
    document.head.appendChild(docStyle);

    function checkPresence() {
      return (
        document.getElementById(
          "moonbounce-ext-container-mbheeaapbjpckahhciogfdodofjjldem"
        )?.shadowRoot != null
      );
    }

    function injectCSS() {
      const shadowRoot = document.querySelector(
        "div#moonbounce-ext-container-mbheeaapbjpckahhciogfdodofjjldem"
      )?.shadowRoot;

      if (!shadowRoot) {
        setTimeout(injectCSS, 500);
        return;
      }

      const moonbouncePortal = shadowRoot.querySelector("#MOONBOUNCE\\.PORTAL");
      if (!moonbouncePortal) {
        setTimeout(injectCSS, 500);
        return;
      }

      const styleElement = document.createElement("style");
      styleElement.textContent = `
        @font-face {
          font-family: 'OpenDyslexic';
          src: url('https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Regular.woff') format('woff');
          font-weight: normal;
          font-style: normal;
          font-display: swap;
        }

        /* Apply to all elements in the shadow DOM */
        * {
          font-family: 'OpenDyslexic' !important;
        }
      `;

      shadowRoot.appendChild(styleElement);
      console.log("%cDyslexia font applied to Moonbounce extension", "background: #44515a; color: #aef0ff; font-size: medium");
    }

    async function runner() {
      const timeStart = performance.now();
      let exists = checkPresence();
      if (!exists) return setTimeout(runner, 500);
      const timeEnd = performance.now();
      injectCSS();
      setTimeout(() => console.log("%c((made with <3 by lune))", "background: #44515a; color: #aef0ff; font-size: x-large; font-style: italic"), 1200);
    }

    runner();
})();