schoolbox web extension :)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(plugins): settings menus not resolving

willow 6378de94 a39df4b5

+12 -37
+2 -6
src/entrypoints/plugins/homepageSwitcher/index.ts
··· 2 2 import { Plugin } from "@/utils/plugin"; 3 3 import type { Toggle } from "@/utils/storage"; 4 4 import type { StorageState } from "@/utils/storage/state.svelte"; 5 - import menu from "./Menu.svelte?url"; 6 5 7 6 let logos: HTMLAnchorElement[] | null = null; 8 7 let controller: AbortController | null = null; ··· 19 18 }, 20 19 false, 21 20 { 22 - config: { 23 - closeCurrentTab: { 24 - toggle: false, 25 - }, 21 + closeCurrentTab: { 22 + toggle: false, 26 23 }, 27 - menu, 28 24 }, 29 25 async (settings) => { 30 26 if (logos !== null) return;
+1 -5
src/entrypoints/plugins/modernIcons/index.ts
··· 9 9 import { Plugin } from "@/utils/plugin"; 10 10 import type { Toggle } from "@/utils/storage"; 11 11 import type { StorageState } from "@/utils/storage/state.svelte"; 12 - import menu from "./Menu.svelte?url"; 13 12 import styleText from "./styles.css?inline"; 14 13 15 14 const ID = "modernIcons"; ··· 27 26 }, 28 27 true, 29 28 { 30 - config: { 31 - filled: { toggle: true }, 32 - }, 33 - menu, 29 + filled: { toggle: true }, 34 30 }, 35 31 36 32 async (settings) => {
+2 -6
src/entrypoints/plugins/scrollPeriod/index.ts
··· 2 2 import { Plugin } from "@/utils/plugin"; 3 3 import type { Slider, Toggle } from "@/utils/storage"; 4 4 import type { StorageState } from "@/utils/storage/state.svelte"; 5 - import menu from "./Menu.svelte?url"; 6 5 7 6 let interval: NodeJS.Timeout | null = null; 8 7 let controller: AbortController | null = null; ··· 20 19 }, 21 20 true, 22 21 { 23 - config: { 24 - resetCooldownOnMouseMove: { toggle: true }, 25 - cooldownDuration: { min: 1, max: 60, value: 10 }, 26 - }, 27 - menu, 22 + resetCooldownOnMouseMove: { toggle: true }, 23 + cooldownDuration: { min: 1, max: 60, value: 10 }, 28 24 }, 29 25 async (settings) => { 30 26 const timetable = document.querySelector("[data-timetable-container] div.scrollable");
+1 -5
src/entrypoints/plugins/subheader/index.ts
··· 3 3 import { Plugin } from "@/utils/plugin"; 4 4 import type { Toggle } from "@/utils/storage"; 5 5 import type { StorageState } from "@/utils/storage/state.svelte"; 6 - import menu from "./Menu.svelte?url"; 7 6 import styleText from "./styles.css?inline"; 8 7 9 8 const ID = "subheader"; ··· 25 24 }, 26 25 true, 27 26 { 28 - config: { 29 - openInNewTab: { toggle: true }, 30 - }, 31 - menu, 27 + openInNewTab: { toggle: true }, 32 28 }, 33 29 async (settings) => { 34 30 const openInNewTab = await settings.openInNewTab.get();
+1 -5
src/entrypoints/plugins/tabTitle/index.ts
··· 1 1 import { Plugin } from "@/utils/plugin"; 2 2 import type { Toggle } from "@/utils/storage"; 3 3 import type { StorageState } from "@/utils/storage/state.svelte"; 4 - import menu from "./Menu.svelte?url"; 5 4 6 5 const ID = "tabTitle"; 7 6 let originalTitle: string | null = null; ··· 18 17 }, 19 18 true, 20 19 { 21 - config: { 22 - showSubjectPrefix: { toggle: true }, 23 - }, 24 - menu, 20 + showSubjectPrefix: { toggle: true }, 25 21 }, 26 22 async (settings) => { 27 23 // if already injected, abort
+2 -2
src/entrypoints/popup/routes/Plugins.svelte
··· 17 17 18 18 onMount(async () => { 19 19 for (const plugin of plugins) { 20 - if (!plugin.menu) continue; 21 - components[plugin.meta.id] = (await import(/* @vite-ignore */ plugin.menu)).default; 20 + if (!plugin.settings) continue; 21 + components[plugin.meta.id] = (await import(`@/entrypoints/plugins/${plugin.meta.id}/Menu.svelte`)).default; 22 22 } 23 23 }); 24 24 </script>
+3 -8
src/utils/plugin.ts
··· 18 18 description: string; 19 19 }, 20 20 defaultToggle: boolean, 21 - settings: { 22 - config: Record<string, object>; 23 - menu: string; 24 - } | null, 21 + settings: Record<string, object> | null, 25 22 private injectCallback: (settings: T) => Promise<void> | void, 26 23 private uninjectCallback: (settings: T) => Promise<void> | void, 27 24 private elementsToWaitFor: string[] = [], 28 25 ) { 29 - if (settings && settings.menu) this.menu = settings.menu; 30 - 31 26 // init plugin storage 32 27 this.toggle = new StorageState( 33 28 storage.defineItem(`local:plugin-${meta.id}`, { 34 29 fallback: { toggle: defaultToggle }, 35 30 }), 36 31 ); 37 - if (settings && settings.config) { 32 + if (settings) { 38 33 this.settings = Object.fromEntries( 39 - Object.entries(settings.config).map(([key, value]) => [ 34 + Object.entries(settings).map(([key, value]) => [ 40 35 key, 41 36 new StorageState( 42 37 storage.defineItem(`local:plugin-${meta.id}-${key}`, {