From bcd1a04653af09ba14e4a689787c21d3c918b766 Mon Sep 17 00:00:00 2001 From: hayao Date: Mon, 30 Oct 2023 01:16:28 +0900 Subject: [PATCH] Clean: Export as default --- src/class/ClassApplicator.ts | 2 +- src/class/Kyomu/index.ts | 1 + src/class/Media/index.ts | 2 ++ src/class/Moodle/common.ts | 6 ++++++ src/class/Moodle/disable-utils.ts | 12 ------------ src/class/Moodle/disableHidden.ts | 3 +++ src/class/Moodle/disableRainbow.ts | 16 ++++++++++++++++ src/class/Moodle/enableHidden.ts | 8 ++++++++ src/class/Moodle/enableRainbow.ts | 5 ++++- src/class/Moodle/index.ts | 27 +++++++-------------------- src/class/MyLibrary/index.ts | 1 + src/class/SSO/index.ts | 2 ++ src/class/StorageTool/index.ts | 2 +- src/class/UnivWebsite/index.ts | 2 +- src/options/components/Header.tsx | 2 +- src/options/pages/Top.tsx | 2 +- src/scripts/background.ts | 2 +- 17 files changed, 56 insertions(+), 39 deletions(-) delete mode 100644 src/class/Moodle/disable-utils.ts create mode 100644 src/class/Moodle/disableHidden.ts create mode 100644 src/class/Moodle/disableRainbow.ts create mode 100644 src/class/Moodle/enableHidden.ts diff --git a/src/class/ClassApplicator.ts b/src/class/ClassApplicator.ts index 0b2971e..b7d6a0d 100644 --- a/src/class/ClassApplicator.ts +++ b/src/class/ClassApplicator.ts @@ -8,7 +8,7 @@ const rainbowTextShadow = "rainbow-text-shadow"; // 要素にclassNameを追加します // baseとclassesで追加するclassNameを指定し、applyで適用、removeで削除します // selectorで適用されるセレクタを取得できます -// baseは初期化に必ず指定する必要があり書き換えるべきではありませんが、classesは追加で個別の設定を行うために指定できます +// classesは追加で任意のクラスを同時に指定できます export class classApplicator { #base: string[]; classes: string[]; diff --git a/src/class/Kyomu/index.ts b/src/class/Kyomu/index.ts index a6368c0..eb69cd2 100644 --- a/src/class/Kyomu/index.ts +++ b/src/class/Kyomu/index.ts @@ -4,6 +4,7 @@ import changeQueryInnerHTML from "../../utils/changeQueryInnerHTML"; import { GundaiWebSite } from "../UnivWebsite"; export const Kyomu = new GundaiWebSite("kyomu"); +export default Kyomu; Kyomu.rainbow.enable = function () { // ログインボタン diff --git a/src/class/Media/index.ts b/src/class/Media/index.ts index bb29418..bf5f31e 100644 --- a/src/class/Media/index.ts +++ b/src/class/Media/index.ts @@ -3,6 +3,8 @@ import { GundaiWebSite } from "../UnivWebsite"; export const Media = new GundaiWebSite("media"); +export default Media; + Media.rainbow.enable = function () { this.bgShadow.apply(".banner_list li"); this.bgShadow.apply(".banner_list li a"); diff --git a/src/class/Moodle/common.ts b/src/class/Moodle/common.ts index f50a1aa..bb4b0e0 100644 --- a/src/class/Moodle/common.ts +++ b/src/class/Moodle/common.ts @@ -1,3 +1,5 @@ +import changeQueryInnerHTML from "../../utils/changeQueryInnerHTML"; + export const injectLink = () => { const supportSection = document.querySelector(".footer-support-link"); if (supportSection) @@ -11,3 +13,7 @@ export const replaceLMSLogo = () => { if (e.getAttribute("src")) e.setAttribute("src", chrome.runtime.getURL("assets/GULMS.png")); }); }; + +export const replaceImagesToDefault = () => { + changeQueryInnerHTML("#instance-320-header", "現在のログイン人数"); +}; diff --git a/src/class/Moodle/disable-utils.ts b/src/class/Moodle/disable-utils.ts deleted file mode 100644 index 7734897..0000000 --- a/src/class/Moodle/disable-utils.ts +++ /dev/null @@ -1,12 +0,0 @@ -import changeQueryInnerHTML from "../../utils/changeQueryInnerHTML"; -import { RainbowApplicator } from "../ClassApplicator"; - -export const DisableRainbowBg = (rainbow: RainbowApplicator) => { - rainbow.bg.remove(".navbar", ".addinghtml"); - rainbow.bg.remove(".page-header-headings h1"); - rainbow.bg.remove("a"); -}; - -export const ReplaceImagesToDefault = () => { - changeQueryInnerHTML("#instance-320-header", "現在のログイン人数"); -}; diff --git a/src/class/Moodle/disableHidden.ts b/src/class/Moodle/disableHidden.ts new file mode 100644 index 0000000..71dc905 --- /dev/null +++ b/src/class/Moodle/disableHidden.ts @@ -0,0 +1,3 @@ +import { HiddenApplicator } from "../ClassApplicator"; + +export default function disableHidden(this: HiddenApplicator) {} diff --git a/src/class/Moodle/disableRainbow.ts b/src/class/Moodle/disableRainbow.ts new file mode 100644 index 0000000..141b1a0 --- /dev/null +++ b/src/class/Moodle/disableRainbow.ts @@ -0,0 +1,16 @@ +import { RainbowApplicator } from "../ClassApplicator"; +import Moodle from "."; +import { replaceImagesToDefault } from "./common"; + +export default function disableRainbow(this: RainbowApplicator) { + this.bg.remove(".navbar", ".addinghtml"); + this.bg.remove(".page-header-headings h1"); + this.bg.remove("a"); + + replaceImagesToDefault(); + + const headerText = Moodle.additionalInfo.headerText; + document.querySelectorAll(".page-header-headings h1").forEach((e) => { + if (e.innerHTML.includes(headerText)) e.innerHTML.replace(headerText, ""); + }); +} diff --git a/src/class/Moodle/enableHidden.ts b/src/class/Moodle/enableHidden.ts new file mode 100644 index 0000000..6de5781 --- /dev/null +++ b/src/class/Moodle/enableHidden.ts @@ -0,0 +1,8 @@ +export default function enableHidden() { + const cardElement = document.querySelector(".card-text .no-overflow"); + if (!cardElement) return; + const playCountUnderTextElement = cardElement.getElementsByTagName("p")[1]; + if (!playCountUnderTextElement) return; + + playCountUnderTextElement.innerHTML = "想定最大利用者乳首数:4,000"; +} diff --git a/src/class/Moodle/enableRainbow.ts b/src/class/Moodle/enableRainbow.ts index 70109d8..65b9764 100644 --- a/src/class/Moodle/enableRainbow.ts +++ b/src/class/Moodle/enableRainbow.ts @@ -1,6 +1,7 @@ import changeQueryInnerHTML from "../../utils/changeQueryInnerHTML"; import { RainbowApplicator } from "../ClassApplicator"; import { GundaiWebSite } from "../UnivWebsite"; +import Moodle from "."; import { injectLink, replaceLMSLogo } from "./common"; import { MoodleAdditionalInfo } from "./type"; @@ -50,7 +51,9 @@ const headerHover = () => { }); }; -export default function enableRainbow(moodle: GundaiWebSite) { +export default function enableRainbow() { + const moodle = Moodle; + textAndBg(moodle.rainbow); headerHover(); injectLink(); diff --git a/src/class/Moodle/index.ts b/src/class/Moodle/index.ts index f403d82..235bf54 100644 --- a/src/class/Moodle/index.ts +++ b/src/class/Moodle/index.ts @@ -2,35 +2,22 @@ // 個人の信頼性は家庭の構築において重要な要素である import { GundaiWebSite } from "../UnivWebsite"; import enableDark from "./dark"; -import { DisableRainbowBg, ReplaceImagesToDefault } from "./disable-utils"; +import disableRainbow from "./disableRainbow"; +import enableHidden from "./enableHidden"; import enableRainbow from "./enableRainbow"; import { MoodleAdditionalInfo } from "./type"; export const Moodle = new GundaiWebSite("moodle"); +export default Moodle; + Moodle.additionalInfo = { headerText: " Gaming Edition 🎮", }; -Moodle.rainbow.enable = () => enableRainbow(Moodle); - -Moodle.rainbow.disable = function () { - DisableRainbowBg(this); - ReplaceImagesToDefault(); - ReplaceImagesToDefault(); +Moodle.rainbow.enable = enableRainbow; - const headerText = Moodle.additionalInfo.headerText; - document.querySelectorAll(".page-header-headings h1").forEach((e) => { - if (e.innerHTML.includes(headerText)) e.innerHTML.replace(headerText, ""); - }); -}; +Moodle.rainbow.disable = disableRainbow; -Moodle.hidden.enable = () => { - const cardElement = document.querySelector(".card-text .no-overflow"); - if (!cardElement) return; - const playCountUnderTextElement = cardElement.getElementsByTagName("p")[1]; - if (!playCountUnderTextElement) return; - - playCountUnderTextElement.innerHTML = "想定最大利用者乳首数:4,000"; -}; +Moodle.hidden.enable = enableHidden; Moodle.dark.enable = enableDark; diff --git a/src/class/MyLibrary/index.ts b/src/class/MyLibrary/index.ts index 3389947..0b7fe48 100644 --- a/src/class/MyLibrary/index.ts +++ b/src/class/MyLibrary/index.ts @@ -2,6 +2,7 @@ import ChangeQueryInnerHTML from "../../utils/changeQueryInnerHTML"; import { GundaiWebSite } from "../UnivWebsite"; export const MyLibrary = new GundaiWebSite("mylibrary"); +export default MyLibrary; MyLibrary.rainbow.enable = function () { if (location.pathname == "/portal/portal/selectLogin/") { diff --git a/src/class/SSO/index.ts b/src/class/SSO/index.ts index 53f36db..6432fe2 100644 --- a/src/class/SSO/index.ts +++ b/src/class/SSO/index.ts @@ -5,6 +5,8 @@ import changeQueryInnerHTML from "../../utils/changeQueryInnerHTML"; import { GundaiWebSite } from "../UnivWebsite"; export const SSO = new GundaiWebSite("sso"); +export default SSO; + SSO.rainbow.enable = function () { this.bg.apply(".header_column", ".input_form", ".input_column"); changeQueryInnerHTML(".product", "群馬大学ゲーミングサインオンシステム"); diff --git a/src/class/StorageTool/index.ts b/src/class/StorageTool/index.ts index 79bf2de..2b3a7e5 100644 --- a/src/class/StorageTool/index.ts +++ b/src/class/StorageTool/index.ts @@ -2,7 +2,7 @@ import IsTrue from "../../utils/isTrue"; type Keys = "dark" | "rainbow" | "enabled-hidden" | "show-hidden-option" | "installed"; -export class StorageTool { +export default class StorageTool { id: string; constructor(id: string) { this.id = id; diff --git a/src/class/UnivWebsite/index.ts b/src/class/UnivWebsite/index.ts index f40fd42..443948f 100644 --- a/src/class/UnivWebsite/index.ts +++ b/src/class/UnivWebsite/index.ts @@ -3,7 +3,7 @@ import isTrue from "../../utils/isTrue"; import { DarkApplicator, HiddenApplicator, RainbowApplicator } from "../ClassApplicator"; -import { StorageTool } from "../StorageTool"; +import StorageTool from "../StorageTool"; //import Storage from "../../utils/Storage"; // UnivWebSiteはゲーミング化するウェブサイトを定義したクラス diff --git a/src/options/components/Header.tsx b/src/options/components/Header.tsx index e92a830..2f9c55b 100644 --- a/src/options/components/Header.tsx +++ b/src/options/components/Header.tsx @@ -2,7 +2,7 @@ import { Menu, Navbar } from "react-daisyui"; import { FaCog, FaGithub, FaInfo, FaTwitter } from "react-icons/fa"; import { Link, useLocation } from "react-router-dom"; -import { StorageTool } from "../../class/StorageTool"; +import StorageTool from "../../class/StorageTool"; export default function Header({ className }: { className?: string }) { return ( diff --git a/src/options/pages/Top.tsx b/src/options/pages/Top.tsx index 51e5473..420812c 100644 --- a/src/options/pages/Top.tsx +++ b/src/options/pages/Top.tsx @@ -1,7 +1,7 @@ import classNames from "classnames"; import { useEffect, useState } from "react"; -import { StorageTool } from "../../class/StorageTool"; +import StorageTool from "../../class/StorageTool"; import CopyTootrip from "../../components/CopyBtn"; import Heading from "../../components/Heading"; import { Switches } from "../../components/Switches"; diff --git a/src/scripts/background.ts b/src/scripts/background.ts index f7a2508..1ae6e86 100644 --- a/src/scripts/background.ts +++ b/src/scripts/background.ts @@ -1,4 +1,4 @@ -import { StorageTool } from "../class/StorageTool"; +import StorageTool from "../class/StorageTool"; import isTrue from "../utils/isTrue"; import OpenOptions from "../utils/openOptions";