Files
BetterSEQTA-Plus/src/plugins/built-in/animatedBackground/index.ts
T
AdenMGB 4fda63dedd refactor: trim PR debloat and fix transformers build
Extract shared helpers for home notices, timetable subtitles, and theme images; dedupe global search, Select, and build scripts while preserving behaviour.

Add @huggingface/transformers as a direct dependency and resolve ORT WASM paths via require.resolve so pnpm postinstall and Vite can bundle vector search.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 10:30:25 +09:30

68 lines
2.0 KiB
TypeScript

import { BasePlugin } from "../../core/settings";
import { type Plugin } from "@/plugins/core/types";
import {
defineSettings,
numberSetting,
Setting,
} from "@/plugins/core/settingsHelpers";
import styles from "./styles.css?inline";
import {
removeAnimatedBackgroundLayers,
syncAnimatedBackground,
updateAnimationSpeed,
} from "./backgroundLayers";
const settings = defineSettings({
speed: numberSetting({
default: 1,
title: "Animation Speed",
description: "Controls how fast the background moves",
min: 0.1,
max: 2,
step: 0.05,
}),
});
class AnimatedBackgroundPluginClass extends BasePlugin<typeof settings> {
@Setting(settings.speed)
speed!: number;
}
const instance = new AnimatedBackgroundPluginClass();
const resync = (api: PluginAPI<typeof settings>) => () => void syncAnimatedBackground(api);
const animatedBackgroundPlugin: Plugin<typeof settings> = {
id: "animated-background",
name: "Animated Background",
description: "Adds an animated background to BetterSEQTA+",
version: "1.0.0",
disableToggle: true,
styles: styles,
settings: instance.settings,
run: async (api) => {
await syncAnimatedBackground(api);
const speedUnregister = api.settings.onChange("speed", updateAnimationSpeed);
const pageChangeUnregister = api.seqta.onPageChange(resync(api));
const pageshowHandler = (event: PageTransitionEvent) => {
if (event.persisted) void syncAnimatedBackground(api);
};
window.addEventListener("pageshow", pageshowHandler);
const containerObserver = new MutationObserver(resync(api));
const container = document.getElementById("container");
if (container) containerObserver.observe(container, { childList: true });
return () => {
speedUnregister.unregister();
pageChangeUnregister.unregister();
window.removeEventListener("pageshow", pageshowHandler);
containerObserver.disconnect();
removeAnimatedBackgroundLayers();
};
},
};
export default animatedBackgroundPlugin;