Moonbounce Dyslexia Theme

Makes the Moonbounce extension components dyslexia friendly

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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();
})();