diff --git a/src/assets/outline.svg b/src/assets/outline.svg new file mode 100644 index 00000000..2ccc0a80 --- /dev/null +++ b/src/assets/outline.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/components/HyperchatButton.svelte b/src/components/HyperchatButton.svelte index 881e185d..6805697c 100644 --- a/src/components/HyperchatButton.svelte +++ b/src/components/HyperchatButton.svelte @@ -1,8 +1,7 @@ + +
+
+
+ {@html outline} +
+
+
HyperChat Settings
+
+ + \ No newline at end of file diff --git a/src/scripts/chat-injector.ts b/src/scripts/chat-injector.ts index 3186a2c0..522275f8 100644 --- a/src/scripts/chat-injector.ts +++ b/src/scripts/chat-injector.ts @@ -1,4 +1,5 @@ import HcButton from '../components/HyperchatButton.svelte'; +import HcSettings from '../components/SettingsButton.svelte'; import { getFrameInfoAsync, isValidFrameInfo, frameIsReplay, checkInjected } from '../ts/chat-utils'; import { isLiveTL } from '../ts/chat-constants'; import { hcEnabled, autoLiveChat } from '../ts/storage'; @@ -75,7 +76,7 @@ const chatLoaded = async (): Promise => { setTheme(isDark); wasDark = isDark; }; - new MutationObserver(sendTheme).observe(html, { + new MutationObserver(sendTheme).observe(document.body, { attributes: true }); sendTheme(); @@ -89,11 +90,27 @@ const chatLoaded = async (): Promise => { console.error('Failed to find #primary-content'); return; } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const hcButton = new HcButton({ + new HcButton({ target: ytcPrimaryContent }); + // Inject HC settings + const injectSettings = (): void => { + // Prevent duplicates + if (document.getElementById('hc-settings')) return; + const ytcItemMenu = document.querySelector('tp-yt-paper-listbox#items'); + if (!ytcItemMenu) return; + + new HcSettings({ + target: ytcItemMenu + }); + } + + new MutationObserver(injectSettings).observe(document.body, { + childList: true, + subtree: true + }); + // Everything past this point will only run if HC is enabled if (!hyperChatEnabled) return; diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts new file mode 100644 index 00000000..79ebb242 --- /dev/null +++ b/src/vite-env.d.ts @@ -0,0 +1,6 @@ +/// + +declare module '*.svg?raw' { + const content: string; + export default content; +}