diff --git a/src/class/Moodle/index.ts b/src/class/Moodle/index.ts index bbcb626..b9864d3 100644 --- a/src/class/Moodle/index.ts +++ b/src/class/Moodle/index.ts @@ -48,3 +48,7 @@ Moodle.hidden.enable = () => { playCountUnderTextElement.innerHTML = "想定最大利用者乳首数:4,000"; }; + +Moodle.dark.enable = () => { + Moodle.dark.base.apply("#page"); +}; diff --git a/src/class/StorageTool/index.ts b/src/class/StorageTool/index.ts index 33dc4c2..79bf2de 100644 --- a/src/class/StorageTool/index.ts +++ b/src/class/StorageTool/index.ts @@ -1,5 +1,7 @@ import IsTrue from "../../utils/isTrue"; +type Keys = "dark" | "rainbow" | "enabled-hidden" | "show-hidden-option" | "installed"; + export class StorageTool { id: string; constructor(id: string) { @@ -11,7 +13,7 @@ export class StorageTool { } // eslint-disable-next-line @typescript-eslint/no-explicit-any - async set(key: string, value: any) { + async set(key: Keys, value: any) { let newData = { [key]: value }; const storage = StorageTool.getChromeStorage(); if (!storage) { @@ -24,7 +26,7 @@ export class StorageTool { storage.set({ [this.id]: newData }); } - async getBool(key: string) { + async getBool(key: Keys) { const storage = StorageTool.getChromeStorage(); if (!storage) { console.error("Storage is not supported"); @@ -35,7 +37,7 @@ export class StorageTool { return IsTrue(rawdata); } - async get(key: string) { + async get(key: Keys) { const storage = StorageTool.getChromeStorage(); if (!storage) { console.error("Storage is not supported"); diff --git a/src/class/UnivWebsite/index.ts b/src/class/UnivWebsite/index.ts index d26ed10..a51c6d9 100644 --- a/src/class/UnivWebsite/index.ts +++ b/src/class/UnivWebsite/index.ts @@ -51,14 +51,15 @@ export class UnivWebsite { site.dark.disable(); } - const isHiddenEnabled = await new StorageTool("other").getBool("enabled-hidden"); + const otherStorage = new StorageTool("other"); + const isHiddenEnabled = await otherStorage.getBool("enabled-hidden"); if (isHiddenEnabled) { document.documentElement.dataset.gaming_gundai_hidden = "true"; - site.storage.set("hidden", "true"); + otherStorage.set("enabled-hidden", "true"); site.hidden.enable(); } else { document.documentElement.dataset.gaming_gundai_hidden = "false"; - site.storage.set("hidden", "false"); + site.storage.set("enabled-hidden", "false"); site.hidden.disable(); } } diff --git a/src/components/SwitchItem.tsx b/src/components/SwitchItem.tsx index 809c7ec..8d80f9d 100644 --- a/src/components/SwitchItem.tsx +++ b/src/components/SwitchItem.tsx @@ -6,13 +6,14 @@ import { useCallback, useEffect, useState } from "react"; import { WebSites } from "../class"; import IsTrue from "../utils/isTrue"; import { FrontConfig } from "./config"; +import { Category } from "./type"; -export function SwitchItem({ config, className }: { config: FrontConfig; className?: string }) { +export function SwitchItem({ config, className, category }: { config: FrontConfig; className?: string; category: Category }) { const [enabled, setEnabled] = useState(false); console.log(`Render SwitchItem with ${config.name}`); useEffect(() => { - WebSites[config.id].storage.get("enabled").then((value) => { + WebSites[config.id].storage.get(category).then((value) => { setEnabled(IsTrue(value)); }); }, []); @@ -20,7 +21,7 @@ export function SwitchItem({ config, className }: { config: FrontConfig; classNa const genericChangeHandle = useCallback(() => { return (e: React.ChangeEvent) => { setEnabled(e.target.checked); - WebSites[config.id].storage.set("enabled", e.target.checked.toString()); + WebSites[config.id].storage.set(category, e.target.checked.toString()); chrome.runtime.sendMessage("reload"); }; }, []); diff --git a/src/components/Switches.tsx b/src/components/Switches.tsx index a44731c..a95441a 100644 --- a/src/components/Switches.tsx +++ b/src/components/Switches.tsx @@ -1,11 +1,12 @@ import { FrontConfigs } from "./config"; import { SwitchItem } from "./SwitchItem"; +import { Category } from "./type"; -export function Switches({ className }: { className?: string }) { +export function Switches({ className, category }: { className?: string; category: Category }) { return ( <> {FrontConfigs.map((config) => { - return ; + return ; })} ); diff --git a/src/components/type.ts b/src/components/type.ts new file mode 100644 index 0000000..3303d3b --- /dev/null +++ b/src/components/type.ts @@ -0,0 +1 @@ +export type Category = "rainbow" | "dark"; diff --git a/src/options/pages/Top.tsx b/src/options/pages/Top.tsx index 54c8ed5..51e5473 100644 --- a/src/options/pages/Top.tsx +++ b/src/options/pages/Top.tsx @@ -10,9 +10,15 @@ import IsTrue from "../../utils/isTrue"; export default function Top() { return ( <> - +
- + +
+
+ + +
+
diff --git a/src/popup/components/Main.tsx b/src/popup/components/Main.tsx index 8f31191..91e5d63 100644 --- a/src/popup/components/Main.tsx +++ b/src/popup/components/Main.tsx @@ -18,7 +18,7 @@ export default function Main(props: MainProps) { [], ); - const switches = ; + const switches = ; const hiddenMsg =

設定画面を表示中はポップアップを利用できません

; return ( diff --git a/src/scripts/content_sso.ts b/src/scripts/content_sso.ts index 3bf50e1..cafefe4 100644 --- a/src/scripts/content_sso.ts +++ b/src/scripts/content_sso.ts @@ -3,6 +3,4 @@ import "/styles/sso.css"; import { SSO } from "../class"; import loadGamingWebsite from "../utils/loadGamingWebsite"; -//window.addEventListener("load", async () => await runFuncIfEnabled(SSO.EnableRainbow)); - loadGamingWebsite(SSO);