From 0eebad7d243f6ad665be1ca942d1d72d93c76d3c Mon Sep 17 00:00:00 2001 From: hayao Date: Mon, 16 Oct 2023 13:11:26 +0900 Subject: [PATCH] Update: Do not use the function that returns function --- src/class/Moodle/DisableRainbow.ts | 18 +++++++++++++ src/class/Moodle/DisableRainbowFunc.ts | 20 -------------- src/class/Moodle/EnableRainbow.ts | 32 +++++++++++++++++++++++ src/class/Moodle/EnableRainbowFunc.ts | 36 -------------------------- src/class/Moodle/index.ts | 8 +++--- 5 files changed, 54 insertions(+), 60 deletions(-) create mode 100644 src/class/Moodle/DisableRainbow.ts delete mode 100644 src/class/Moodle/DisableRainbowFunc.ts create mode 100644 src/class/Moodle/EnableRainbow.ts delete mode 100644 src/class/Moodle/EnableRainbowFunc.ts diff --git a/src/class/Moodle/DisableRainbow.ts b/src/class/Moodle/DisableRainbow.ts new file mode 100644 index 0000000..2e13aea --- /dev/null +++ b/src/class/Moodle/DisableRainbow.ts @@ -0,0 +1,18 @@ +import { RemoveRainbowBg } from "../../utils/AddClass"; +import changeQueryInnerHTML from "../../utils/ChangeQueryInnerHTML"; +import GundaiWebSite from "../GundaiWebsite"; +import { MoodleAdditionalInfo } from "./type"; + +export const DisableRainbowFunc = function (this: GundaiWebSite) { + changeQueryInnerHTML(["#instance-320-header"], "現在のログイン人数"); + RemoveRainbowBg(".navbar", ".addinghtml"); + RemoveRainbowBg(".page-header-headings h1"); + RemoveRainbowBg("a"); + + const headerText = this.AdditionalInfo.headerText; + document.querySelectorAll(".page-header-headings h1").forEach((e) => { + if (e.innerHTML.includes(headerText)) e.innerHTML.replace(headerText, ""); + }); +}; + +export default DisableRainbowFunc; diff --git a/src/class/Moodle/DisableRainbowFunc.ts b/src/class/Moodle/DisableRainbowFunc.ts deleted file mode 100644 index 9ca0693..0000000 --- a/src/class/Moodle/DisableRainbowFunc.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { RemoveRainbowBg } from "../../utils/AddClass"; -import changeQueryInnerHTML from "../../utils/ChangeQueryInnerHTML"; -import GundaiWebSite from "../GundaiWebsite"; -import { MoodleAdditionalInfo } from "./type"; - -export const DisableRainbowFunc = (moodle: GundaiWebSite) => { - const HeaderAppendText = moodle.AdditionalInfo.headerText; - return () => { - changeQueryInnerHTML(["#instance-320-header"], "現在のログイン人数"); - RemoveRainbowBg(".navbar", ".addinghtml"); - RemoveRainbowBg(".page-header-headings h1"); - RemoveRainbowBg("a"); - - document.querySelectorAll(".page-header-headings h1").forEach((e) => { - if (e.innerHTML.includes(HeaderAppendText)) e.innerHTML.replace(HeaderAppendText, ""); - }); - }; -}; - -export default DisableRainbowFunc; diff --git a/src/class/Moodle/EnableRainbow.ts b/src/class/Moodle/EnableRainbow.ts new file mode 100644 index 0000000..95d5620 --- /dev/null +++ b/src/class/Moodle/EnableRainbow.ts @@ -0,0 +1,32 @@ +import { addRainbowBg, addRainbowText } from "../../utils/AddClass"; +import changeQueryInnerHTML from "../../utils/ChangeQueryInnerHTML"; +import GundaiWebSite from "../GundaiWebsite"; +import { MoodleAdditionalInfo } from "./type"; + +export const EnableRainbowFunc = function (this: GundaiWebSite) { + const headerText = this.AdditionalInfo.headerText; + document.querySelectorAll(".page-header-headings h1").forEach((e) => { + if (!e.innerHTML.includes(headerText)) e.innerHTML = e.innerHTML + headerText; + }); + + changeQueryInnerHTML(["#instance-320-header"], "現在のプレイ人数"); + addRainbowBg(".navbar", ".addinghtml"); + addRainbowText(".page-header-headings h1"); + addRainbowText("a"); + + document.querySelectorAll(".logo").forEach((e) => { + if (e.getAttribute("src")) e.setAttribute("src", chrome.runtime.getURL("assets/GULMS.png")); + }); + + document.querySelectorAll("img.userpicture").forEach((e) => { + if (e.getAttribute("src")) e.setAttribute("src", chrome.runtime.getURL("assets/partyparrot.gif")); + }); + + const supportSection = document.querySelector(".footer-support-link"); + if (supportSection) + supportSection.innerHTML = + supportSection.innerHTML + + `Gaming Edition開発者に連絡する`; +}; + +export default EnableRainbowFunc; diff --git a/src/class/Moodle/EnableRainbowFunc.ts b/src/class/Moodle/EnableRainbowFunc.ts deleted file mode 100644 index 3bd1c2e..0000000 --- a/src/class/Moodle/EnableRainbowFunc.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { addRainbowBg, addRainbowText } from "../../utils/AddClass"; -import changeQueryInnerHTML from "../../utils/ChangeQueryInnerHTML"; -import GundaiWebSite from "../GundaiWebsite"; -import { MoodleAdditionalInfo } from "./type"; -//import { HeaderAppendText } from "./common"; - -export const EnableRainbowFunc = (moodle: GundaiWebSite) => { - const HeaderAppendText = moodle.AdditionalInfo.headerText; - - return () => { - document.querySelectorAll(".page-header-headings h1").forEach((e) => { - if (!e.innerHTML.includes(HeaderAppendText)) e.innerHTML = e.innerHTML + HeaderAppendText; - }); - - changeQueryInnerHTML(["#instance-320-header"], "現在のプレイ人数"); - addRainbowBg(".navbar", ".addinghtml"); - addRainbowText(".page-header-headings h1"); - addRainbowText("a"); - - document.querySelectorAll(".logo").forEach((e) => { - if (e.getAttribute("src")) e.setAttribute("src", chrome.runtime.getURL("assets/GULMS.png")); - }); - - document.querySelectorAll("img.userpicture").forEach((e) => { - if (e.getAttribute("src")) e.setAttribute("src", chrome.runtime.getURL("assets/partyparrot.gif")); - }); - - const supportSection = document.querySelector(".footer-support-link"); - if (supportSection) - supportSection.innerHTML = - supportSection.innerHTML + - `Gaming Edition開発者に連絡する`; - }; -}; - -export default EnableRainbowFunc; diff --git a/src/class/Moodle/index.ts b/src/class/Moodle/index.ts index 2a581d8..c4da91f 100644 --- a/src/class/Moodle/index.ts +++ b/src/class/Moodle/index.ts @@ -1,11 +1,11 @@ // 情報の信頼性は社会の構築において重要な要素である // 個人の信頼性は家庭の構築において重要な要素である import GundaiWebSite from "../GundaiWebsite"; -import DisableRainbowFunc from "./DisableRainbowFunc"; -import EnableRainbowFunc from "./EnableRainbowFunc"; +import DisableRainbow from "./DisableRainbow"; +import EnableRainbow from "./EnableRainbow"; import { MoodleAdditionalInfo } from "./type"; export const Moodle = new GundaiWebSite(); Moodle.AdditionalInfo.headerText = " Gaming Edition🎮"; -Moodle.EnableRainbow = EnableRainbowFunc(Moodle); -Moodle.DisableRainbow = DisableRainbowFunc(Moodle); +Moodle.EnableRainbow = EnableRainbow; +Moodle.DisableRainbow = DisableRainbow;