-
-## Documentation
-
-Everything you need to get started with BetterSEQTA+ can be found in the [official documentation](https://docs.betterseqta.org).
-
-Includes:
-- Getting Started
-- Installation & Development
-- Architecture
-- Plugin System
-- Theme Creation
+
-
- Powered by My First Plugin
-
- `;
-
- return welcomeElement;
- };
-
- // Function to add message to homepage
- const addToHomepage = () => {
- api.seqta.onMount(".home-page, .dashboard, [class*='home']", (homePage) => {
- console.log("[My First Plugin] Found homepage, adding welcome message");
-
- const message = createWelcomeMessage();
- if (message) {
- // Add to the top of the homepage
- homePage.insertBefore(message, homePage.firstChild);
- }
- });
- };
-
- // Add message when plugin starts
- addToHomepage();
-
- // Re-add message when user navigates to homepage
- api.seqta.onPageChange((page) => {
- console.log("[My First Plugin] Page changed to:", page);
- if (page.includes("home") || page.includes("dashboard")) {
- // Small delay to let the page load
- setTimeout(addToHomepage, 500);
- }
- });
-
- // Listen for settings changes and update the message
- api.settings.onChange("enabled", (enabled) => {
- console.log("[My First Plugin] Enabled setting changed:", enabled);
- if (enabled) {
- addToHomepage();
- } else if (welcomeElement) {
- welcomeElement.remove();
- welcomeElement = null;
- }
- });
-
- api.settings.onChange("customMessage", (newMessage) => {
- console.log("[My First Plugin] Message changed:", newMessage);
- if (welcomeElement && api.settings.enabled) {
- // Update existing message
- addToHomepage();
- }
- });
-
- api.settings.onChange("showEmoji", (showEmoji) => {
- console.log("[My First Plugin] Show emoji changed:", showEmoji);
- if (welcomeElement && api.settings.enabled) {
- // Update existing message
- addToHomepage();
- }
- });
-
- // Return cleanup function (called when plugin is disabled)
- return () => {
- console.log("[My First Plugin] Cleaning up...");
- if (welcomeElement) {
- welcomeElement.remove();
- welcomeElement = null;
- }
- };
- }
-};
-
-export default myFirstPlugin;
-```
-
-## How to Use This Example
-
-### Step 1: Create the Plugin File
-1. Create a new folder: `src/plugins/built-in/my-first-plugin/`
-2. Create `index.ts` in that folder
-3. Copy the code above into `index.ts`
-
-### Step 2: Register the Plugin
-Add this to `src/plugins/index.ts`:
-
-```typescript
-// Add this import at the top
-import myFirstPlugin from "./built-in/my-first-plugin";
-
-// Add this line where other plugins are registered
-pluginManager.registerPlugin(myFirstPlugin);
-```
-
-### Step 3: Test It
-1. Run `npm run dev`
-2. Reload your extension in Chrome
-3. Visit a SEQTA page
-4. You should see your welcome message!
-5. Open BetterSEQTA+ settings to customize it
-
-## Key Concepts Explained
-
-### 1. Plugin Structure
-```typescript
-const myPlugin: Plugin = {
- id: "unique-id", // Must be unique across all plugins
- name: "Display Name", // Shown in settings
- description: "What it does", // Shown in settings
- version: "1.0.0", // Plugin version
- settings: settingsObject, // User-configurable options
- styles: "/* CSS here */", // Optional CSS styles
- run: async (api) => { // Main plugin code
- // Your code here
- }
-};
-```
-
-### 2. Settings System
-```typescript
-// Define what settings your plugin has
-const settings = defineSettings({
- myOption: booleanSetting({
- default: true,
- title: "My Option",
- description: "What this option does"
- })
-});
-
-// Use in your plugin
-if (api.settings.myOption) {
- // Do something
-}
-```
-
-### 3. SEQTA Integration
-```typescript
-// Wait for elements to appear
-api.seqta.onMount(".some-selector", (element) => {
- // Modify the element
-});
-
-// Detect page changes
-api.seqta.onPageChange((page) => {
- if (page === "home") {
- // User navigated to homepage
- }
-});
-```
-
-### 4. Cleanup
-Always return a cleanup function to remove your changes when the plugin is disabled:
-
-```typescript
-run: async (api) => {
- // Add your features
-
- return () => {
- // Remove your features
- };
-}
-```
-
-## Customization Ideas
-
-Want to modify this example? Here are some ideas:
-
-1. **Change the styling**: Modify the CSS to use different colors, animations, or layouts
-2. **Add more settings**: Number settings, select dropdowns, hotkeys
-3. **Different trigger**: Show on different pages, or based on time of day
-4. **Add interactions**: Buttons that do things when clicked
-5. **Store data**: Use `api.storage` to remember user preferences
-6. **Communicate with other plugins**: Use `api.events` to send/receive events
-
-## Next Steps
-
-Once you've got this working:
-
-1. **Experiment**: Try changing things and see what happens
-2. **Read other plugins**: Look at the built-in plugins for inspiration
-3. **Check the API docs**: Learn about all available API functions
-4. **Share your creation**: Show it off in Discord!
-
-## Need Help?
-
-- π¬ Ask in our [Discord server](https://discord.gg/YzmbnCDkat)
-- π Read the [plugin documentation](https://docs.betterseqta.org/plugins/)
-- π Check the [troubleshooting guide](https://docs.betterseqta.org/troubleshooting/)
-- π Open an issue on GitHub
-
-Happy coding! π
\ No newline at end of file
diff --git a/docs/plugins/README.md b/docs/plugins/README.md
deleted file mode 100644
index 7e64853f..00000000
--- a/docs/plugins/README.md
+++ /dev/null
@@ -1,299 +0,0 @@
-# Creating Plugins for BetterSEQTA+
-
-**Published version:** [docs.betterseqta.org/plugins/](https://docs.betterseqta.org/plugins/) Β· [Plugin development](https://docs.betterseqta.org/plugin-development/) Β· [Plugin API](https://docs.betterseqta.org/plugin-api/)
-
-Hey there! π So you want to create a plugin for BetterSEQTA+? That's awesome! This guide will walk you through everything you need to know, from the very basics to more advanced features. Don't worry if you're new to this - we'll explain everything step by step.
-
-## What is a Plugin?
-
-In BetterSEQTA+, a plugin is like a mini-app that adds new features to SEQTA. Think of it as a piece of LEGO that you can snap onto SEQTA to make it do new things. For example, you could create a plugin that:
-
-- Changes how SEQTA looks
-- Adds new buttons or features
-- Shows extra information on your timetable
-- Collects notifications in a better way
-- Really, anything you can imagine!
-
-## Your First Plugin
-
-Let's create a super simple plugin together. We'll make one that adds a friendly message to the SEQTA homepage. Here's what we'll need:
-
-```typescript
-import type { Plugin } from "@/plugins/core/types";
-
-const myFirstPlugin: Plugin = {
- // Every plugin needs these basic details
- id: "my-first-plugin",
- name: "My First Plugin",
- description: "Adds a friendly message to SEQTA",
- version: "1.0.0",
-
- // This tells BetterSEQTA+ that users can turn our plugin on/off
- disableToggle: true,
-
- // Optional: Mark your plugin as beta to show a "Beta" tag in settings
- beta: true,
-
- // This is where the magic happens!
- run: async (api) => {
- // Wait for the homepage to load
- api.seqta.onMount(".home-page", (homePage) => {
- // Create our message
- const message = document.createElement("div");
- message.textContent = "Hello from my first plugin! π";
- message.style.padding = "20px";
- message.style.backgroundColor = "#e9f5ff";
- message.style.borderRadius = "8px";
- message.style.margin = "20px";
-
- // Add it to the page
- homePage.prepend(message);
- });
-
- // Return a cleanup function that removes our message when the plugin is disabled
- return () => {
- const message = document.querySelector(".home-page > div");
- message?.remove();
- };
- },
-};
-
-export default myFirstPlugin;
-```
-
-Let's break down what's happening here:
-
-1. First, we import the `Plugin` type that tells TypeScript what a plugin should look like
-2. We create our plugin object with some basic information:
- - `id`: A unique name for your plugin (use lowercase and dashes)
- - `name`: A friendly name that users will see
- - `description`: Explain what your plugin does
- - `version`: Your plugin's version number
-3. We set `disableToggle: true` so users can turn our plugin on/off in settings
-4. We set `beta: true` to mark the plugin as beta
-5. The `run` function is where we put our plugin's code
-6. We use `api.seqta.onMount` to wait for the homepage to load
-7. We create and style a message element
-8. We return a cleanup function that removes our changes when the plugin is disabled
-
-## The Plugin API
-
-When your plugin runs, it gets access to a powerful API that lets you do all sorts of things. Let's look at what you can do:
-
-### SEQTA API (`api.seqta`)
-
-This helps you interact with SEQTA's pages:
-
-```typescript
-// Wait for an element to appear on the page
-api.seqta.onMount(".some-class", (element) => {
- // Do something with the element
-});
-
-// Know when the user changes pages
-api.seqta.onPageChange((page) => {
- console.log("User went to:", page);
-});
-
-// Get the current page
-const currentPage = api.seqta.getCurrentPage();
-```
-
-### Settings API (`api.settings`)
-
-Want to let users customize your plugin? Use settings!
-
-```typescript
-import { BasePlugin } from "@/plugins/core/settings";
-import {
- booleanSetting,
- defineSettings,
- Setting,
-} from "@/plugins/core/settingsHelpers";
-
-// Define your settings
-const settings = defineSettings({
- showMessage: booleanSetting({
- default: true,
- title: "Show Welcome Message",
- description: "Show a friendly message on the homepage",
- }),
-});
-
-// Create a class for your plugin
-class MyPluginClass extends BasePlugin {
- @Setting(settings.showMessage)
- showMessage!: boolean;
-}
-
-// Create your plugin
-const settingsInstance = new MyPluginClass();
-
-const myPlugin: Plugin = {
- // ... other plugin details ...
- settings: settingsInstance.settings,
-
- run: async (api) => {
- // Use the setting
- if (api.settings.showMessage) {
- // Show the message
- }
-
- // Listen for setting changes
- api.settings.onChange("showMessage", (newValue) => {
- if (newValue) {
- // Show the message
- } else {
- // Hide the message
- }
- });
- },
-};
-```
-
-### Storage API (`api.storage`)
-
-Need to save some data? The storage API has got you covered:
-
-```typescript
-// Save some data
-await api.storage.set("lastVisit", new Date().toISOString());
-
-// Get it back later
-const lastVisit = await api.storage.get("lastVisit");
-
-// Listen for changes
-api.storage.onChange("lastVisit", (newValue) => {
- console.log("Last visit updated:", newValue);
-});
-```
-
-### Events API (`api.events`)
-
-Want your plugin to be able to interface with other plugins? Then use events!
-
-```typescript
-// Listen for an event
-api.events.on("myCustomEvent", (data) => {
- console.log("Got event:", data);
-});
-
-// Send an event
-api.events.emit("myCustomEvent", { some: "data" });
-```
-
-## Adding Styles
-
-Want to make your plugin look pretty? You can add CSS styles:
-
-```typescript
-const myPlugin: Plugin = {
- // ... other plugin details ...
-
- // Add your CSS here
- styles: `
- .my-plugin-message {
- background: linear-gradient(135deg, #6e8efb, #a777e3);
- color: white;
- padding: 20px;
- border-radius: 12px;
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
- margin: 20px;
- animation: slide-in 0.3s ease-out;
- }
-
- @keyframes slide-in {
- from { transform: translateY(-20px); opacity: 0; }
- to { transform: translateY(0); opacity: 1; }
- }
- `,
-
- run: async (api) => {
- // Your plugin code here
- },
-};
-```
-
-## Best Practices
-
-Here are some tips to make your plugin awesome:
-
-1. **Always Clean Up**: When your plugin is disabled, clean up any changes you made:
-
- ```typescript
- run: async (api) => {
- // Add stuff to the page
- const element = document.createElement("div");
- document.body.appendChild(element);
-
- // Return a cleanup function
- return () => {
- element.remove();
- };
- };
- ```
-
-2. **Use TypeScript**: It helps catch errors before they happen and makes your code easier to understand.
-
-3. **Test Your Plugin**: Make sure it works in different situations:
-
- - When SEQTA is loading
- - When the user switches pages
- - When the plugin is enabled/disabled
- - When settings are changed
-
-4. **Keep It Fast**: Don't slow down SEQTA:
-
- - Use `onMount` instead of intervals or timeouts
- - Clean up event listeners when they're not needed
- - Don't do heavy calculations on the main thread
-
-5. **Make It User-Friendly**:
- - Add clear settings with good descriptions
- - Use `disableToggle: true` so users can turn it off if needed
- - Add helpful error messages if something goes wrong
- - Use `beta: true` for experimental features to let users know they're trying something new
-
-## Plugin Metadata Options
-
-Your plugin object supports several optional flags to customize how it appears and behaves:
-
-```typescript
-const myPlugin: Plugin = {
- id: "my-plugin",
- name: "My Plugin",
- description: "What my plugin does",
- version: "1.0.0",
-
- // Optional flags:
- disableToggle: true, // Show enable/disable toggle in settings
- defaultEnabled: false, // Start disabled by default (requires disableToggle: true)
- beta: true, // Show "Beta" tag in settings UI
-
- // Your plugin code...
- run: async (api) => { /* ... */ },
-};
-```
-
-- **`disableToggle`**: When `true`, users can enable/disable your plugin in settings
-- **`defaultEnabled`**: When `false`, your plugin starts disabled (only works with `disableToggle: true`)
-- **`beta`**: When `true`, shows an orange "Beta" tag next to your plugin name in settings
-
-## Examples
-
-Want to see more examples? Check out our built-in plugins:
-
-- [themes](../../src/plugins/built-in/themes/index.ts): Shows how to change SEQTA's appearance
-- [notificationCollector](../../src/plugins/built-in/notificationCollector/index.ts): Shows how to work with SEQTA's notifications
-- [timetable](../../src/plugins/built-in/timetable/index.ts): Shows how to modify SEQTA's timetable view
-- [assessmentsAverage](../../src/plugins/built-in/assessmentsAverage/index.ts): Shows how to add new features to existing pages
-
-## Need Help?
-
-Got stuck? No worries! Here's where you can get help:
-
-- Join our [Discord server](https://discord.gg/YzmbnCDkat)
-- Check out the built-in plugins in the `src/plugins/built-in` folder
-- Open an issue on our [GitHub page](https://github.com/betterseqta/betterseqta-plus/issues)
-
-Happy coding and feel free to check out the [plugin API](https://docs.betterseqta.org/plugin-api/) on the documentation site.
diff --git a/docs/plugins/api-reference.md b/docs/plugins/api-reference.md
deleted file mode 100644
index 620106a4..00000000
--- a/docs/plugins/api-reference.md
+++ /dev/null
@@ -1,368 +0,0 @@
-# Plugin API Reference
-
-**Published version:** [docs.betterseqta.org/plugin-api/](https://docs.betterseqta.org/plugin-api/)
-
-This document provides detailed technical information about BetterSEQTA+'s plugin APIs. For a beginner-friendly introduction, see the [plugins section](https://docs.betterseqta.org/plugins/) at [docs.betterseqta.org](https://docs.betterseqta.org/).
-
-## Plugin Structure
-
-Here's how a plugin is structured:
-
-```typescript
-import type { Plugin } from "@/plugins/core/types";
-import { BasePlugin } from "@/plugins/core/settings";
-import {
- booleanSetting,
- defineSettings,
- Setting,
-} from "@/plugins/core/settingsHelpers";
-
-// First, define your settings
-const settings = defineSettings({
- enabled: booleanSetting({
- default: true,
- title: "Enable Feature",
- description: "Turn this feature on or off",
- }),
-});
-
-// Create a class to handle your settings
-class MyPluginClass extends BasePlugin {
- @Setting(settings.enabled)
- enabled!: boolean;
-}
-
-// Create an instance of your settings
-const settingsInstance = new MyPluginClass();
-
-// Create your plugin
-const myPlugin: Plugin = {
- id: "my-plugin",
- name: "My Plugin",
- description: "A cool plugin that does things",
- version: "1.0.0",
- settings: settingsInstance.settings,
- disableToggle: true,
- beta: true,
-
- run: async (api) => {
- console.log("Plugin is running!");
-
- // Do stuff when settings change
- api.settings.onChange("enabled", (enabled) => {
- if (enabled) {
- console.log("Feature enabled!");
- }
- });
-
- // Return a cleanup function
- return () => {
- console.log("Plugin cleanup");
- };
- },
-};
-
-export default myPlugin;
-```
-
-## Plugin Metadata
-
-The plugin object supports several metadata fields and options:
-
-```typescript
-interface Plugin {
- // Required fields
- id: string; // Unique identifier (lowercase, dashes)
- name: string; // Display name shown to users
- description: string; // Brief description of what the plugin does
- version: string; // Semantic version (e.g., "1.0.0")
- settings: PluginSettings; // Plugin settings object
- run: (api: PluginAPI) => void; // Main plugin function
-
- // Optional fields
- styles?: string; // CSS styles to inject
- disableToggle?: boolean; // Show enable/disable toggle in settings
- defaultEnabled?: boolean; // Start enabled/disabled (requires disableToggle)
- beta?: boolean; // Show "Beta" tag in settings UI
-}
-```
-
-### Metadata Options
-
-- **`disableToggle`**: When `true`, users can enable/disable your plugin in the settings page
-- **`defaultEnabled`**: When `false`, your plugin starts disabled by default (only works with `disableToggle: true`)
-- **`beta`**: When `true`, displays an orange "Beta" tag next to your plugin name in the settings UI
-- **`styles`**: CSS string that gets injected into the page when your plugin runs
-
-## SEQTA API
-
-The SEQTA API helps you interact with SEQTA's pages:
-
-```typescript
-import type { Plugin } from "@/plugins/core/types";
-
-const seqtaPlugin: Plugin = {
- id: "seqta-example",
- name: "SEQTA Example",
- description: "Shows how to use the SEQTA API",
- version: "1.0.0",
- settings: {},
- disableToggle: true,
-
- run: async (api) => {
- // Wait for elements to appear
- const { unregister: timetableUnregister } = api.seqta.onMount(
- ".timetable",
- (timetable) => {
- const button = document.createElement("button");
- button.textContent = "Export";
- timetable.appendChild(button);
- },
- );
-
- // Track page changes
- const { unregister: pageUnregister } = api.seqta.onPageChange((page) => {
- console.log("User went to:", page);
- });
-
- // Clean up when disabled
- return () => {
- timetableUnregister();
- pageUnregister();
- };
- },
-};
-
-export default seqtaPlugin;
-```
-
-## Settings API
-
-Here's how to add settings to your plugin:
-
-```typescript
-import type { Plugin } from "@/plugins/core/types";
-import { BasePlugin } from "@/plugins/core/settings";
-import {
- booleanSetting,
- stringSetting,
- numberSetting,
- selectSetting,
- defineSettings,
- Setting,
-} from "@/plugins/core/settingsHelpers";
-
-// Define your settings
-const settings = defineSettings({
- darkMode: booleanSetting({
- default: false,
- title: "Dark Mode",
- description: "Enable dark mode",
- }),
- userName: stringSetting({
- default: "",
- title: "User Name",
- description: "Your display name",
- placeholder: "Enter your name...",
- }),
- theme: selectSetting({
- default: "light",
- title: "Theme",
- description: "Choose your theme",
- options: [
- { value: "light", label: "Light" },
- { value: "dark", label: "Dark" },
- ],
- }),
-});
-
-// Create your settings class
-class ThemePluginClass extends BasePlugin {
- @Setting(settings.darkMode)
- darkMode!: boolean;
-
- @Setting(settings.userName)
- userName!: string;
-
- @Setting(settings.theme)
- theme!: string;
-}
-
-// Create the plugin
-const themePlugin: Plugin = {
- id: "theme-example",
- name: "Theme Example",
- description: "Shows how to use settings",
- version: "1.0.0",
- settings: new ThemePluginClass().settings,
- disableToggle: true,
-
- run: async (api) => {
- // Apply initial settings
- if (api.settings.darkMode) {
- document.body.classList.add("dark");
- }
-
- // Listen for changes
- const { unregister } = api.settings.onChange("darkMode", (enabled) => {
- document.body.classList.toggle("dark", enabled);
- });
-
- return () => {
- unregister();
- document.body.classList.remove("dark");
- };
- },
-};
-
-export default themePlugin;
-```
-
-## Storage API
-
-Here's how to use storage in your plugin:
-
-```typescript
-import type { Plugin } from "@/plugins/core/types";
-
-const storagePlugin: Plugin = {
- id: "storage-example",
- name: "Storage Example",
- description: "Shows how to use storage",
- version: "1.0.0",
- settings: {},
- disableToggle: true,
-
- run: async (api) => {
- // Wait for storage to be ready
- await api.storage.loaded;
-
- // Save some data
- await api.storage.set("lastVisit", new Date().toISOString());
-
- // Get saved data
- const lastVisit = await api.storage.get("lastVisit");
- console.log("Last visit:", lastVisit);
-
- // Listen for changes
- const { unregister } = api.storage.onChange("lastVisit", (newValue) => {
- console.log("Last visit updated:", newValue);
- });
-
- return () => {
- unregister();
- };
- },
-};
-
-export default storagePlugin;
-```
-
-## Events API
-
-Here's how to use events in your plugin:
-
-```typescript
-import type { Plugin } from "@/plugins/core/types";
-
-const eventsPlugin: Plugin = {
- id: "events-example",
- name: "Events Example",
- description: "Shows how to use events",
- version: "1.0.0",
- settings: {},
- disableToggle: true,
-
- run: async (api) => {
- // Listen for theme changes
- const { unregister: themeListener } = api.events.on(
- "theme.changed",
- (theme) => {
- console.log("Theme changed to:", theme);
- },
- );
-
- // Listen for notifications
- const { unregister: notifyListener } = api.events.on(
- "notification.new",
- (notification) => {
- console.log("New notification:", notification);
- },
- );
-
- // Clean up listeners
- return () => {
- themeListener();
- notifyListener();
- };
- },
-};
-
-export default eventsPlugin;
-```
-
-## Performance Tips
-
-Here's how to write efficient plugins:
-
-```typescript
-import type { Plugin } from "@/plugins/core/types";
-
-const efficientPlugin: Plugin = {
- id: "efficient-example",
- name: "Efficient Example",
- description: "Shows performance best practices",
- version: "1.0.0",
- settings: {},
- disableToggle: true,
-
- run: async (api) => {
- // β Good: Use onMount
- const { unregister } = api.seqta.onMount(".timetable", (el) => {
- el.classList.add("enhanced");
- });
-
- // β Bad: Don't use intervals
- // const interval = setInterval(() => {
- // const el = document.querySelector('.timetable');
- // if (el) el.classList.add('enhanced');
- // }, 100);
-
- // β Good: Cache DOM elements
- const header = document.querySelector(".header");
- if (header) {
- // Reuse header instead of querying again
- }
-
- // β Good: Batch DOM updates
- const fragment = document.createDocumentFragment();
- for (let i = 0; i < 10; i++) {
- const div = document.createElement("div");
- fragment.appendChild(div);
- }
- document.body.appendChild(fragment);
-
- return () => {
- unregister();
- // clearInterval(interval); // If you used the bad approach
- };
- },
-};
-
-export default efficientPlugin;
-```
-
-Each plugin should be in its own file and exported as the default export. The plugin should:
-
-1. Import necessary types and helpers
-2. Define settings if needed
-3. Create a settings class if using settings
-4. Create the plugin object with proper type annotation
-5. Export the plugin as default
-
-Remember to always:
-
-- Use proper TypeScript types
-- Clean up when your plugin is disabled
-- Handle errors gracefully
-- Follow the plugin structure shown above
diff --git a/lib/touchGlobalCSS.ts b/lib/touchGlobalCSS.ts
deleted file mode 100644
index 0065a3f0..00000000
--- a/lib/touchGlobalCSS.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import type { Plugin } from "vite";
-
-/**
- * Previously touched CSS mtimes on JS HMR to force style refresh.
- * That raced with CRXJS runtime reload and corrupted Vite's module graph
- * (missing named/`default` exports until `npm run dev` was restarted).
- *
- * Style updates are now covered by `stabilizeCrxDevHmr` full reloads.
- */
-export default function touchGlobalCSSPlugin(): Plugin {
- return {
- name: "touch-global-css",
- apply: "serve",
- };
-}
diff --git a/src/background.ts b/src/background.ts
index 93fe310a..fb86099a 100644
--- a/src/background.ts
+++ b/src/background.ts
@@ -183,7 +183,6 @@ function isTrustedSender(sender?: browser.Runtime.MessageSender): boolean {
try {
if (isSeqtaOrigin(new URL(pageUrl).origin)) return true;
} catch {
- // try next URL
}
}
return false;
@@ -335,7 +334,6 @@ function initCloudLoginCallbackListener() {
const userId = url.searchParams.get("user_id");
if (token && refreshToken) {
- // Store tokens
void (async () => {
try {
await browser.storage.local.set({
@@ -343,7 +341,6 @@ function initCloudLoginCallbackListener() {
bsplus_refresh_token: refreshToken,
});
- // Fetch full user info
const userRes = await fetch("https://accounts.betterseqta.org/api/auth/me", {
headers: { Authorization: `Bearer ${token}` },
});
@@ -354,7 +351,6 @@ function initCloudLoginCallbackListener() {
await browser.storage.local.set({ bsplus_user: { id: userId } });
}
- // Trigger cloud settings download
void performCloudSettingsDownloadWithRetry(token).catch((err) => {
console.warn("[Background] Cloud settings download after login:", err);
});
@@ -363,7 +359,6 @@ function initCloudLoginCallbackListener() {
}
})();
- // Close the callback tab
void browser.tabs.remove(tabId);
}
} catch (err) {
diff --git a/src/interface/components/CodeEditor.svelte b/src/interface/components/CodeEditor.svelte
index d8e469e5..1097afa2 100644
--- a/src/interface/components/CodeEditor.svelte
+++ b/src/interface/components/CodeEditor.svelte
@@ -11,10 +11,8 @@
import { color } from '@uiw/codemirror-extensions-color'
import { Compartment } from '@codemirror/state';
- // Theme
import { githubLight, githubDark } from '@uiw/codemirror-theme-github';
- // Language
import { css } from "@codemirror/lang-css";
let editor = $state(null)
diff --git a/src/interface/components/HotkeyInput.svelte b/src/interface/components/HotkeyInput.svelte
index 11465f1a..a6c7738f 100644
--- a/src/interface/components/HotkeyInput.svelte
+++ b/src/interface/components/HotkeyInput.svelte
@@ -33,7 +33,6 @@
};
const formatKeyForDisplay = (key: string): string => {
- // Map keys to their display format
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
const keyMap: Record = {
'ctrl': isMac ? 'β' : 'Ctrl',
@@ -70,7 +69,6 @@
if (parsed.alt) parts.push('alt');
if (parsed.shift) parts.push('shift');
- // Add the main key
if (parsed.key) parts.push(parsed.key);
return parts;
@@ -92,7 +90,6 @@
return;
}
- // Build the hotkey string
const modifiers: string[] = [];
let mainKey = '';
@@ -131,7 +128,6 @@
const key = formatKeyForHotkey(e.key);
- // Add modifiers
if (e.ctrlKey) addRecordedKey('ctrl');
if (e.metaKey) addRecordedKey('cmd');
if (e.altKey) addRecordedKey('alt');
@@ -166,7 +162,6 @@
}
});
- // Get the parts to display
const hotkeyParts = $derived(isRecording
? Array.from(recordedKeys).map(formatKeyForDisplay)
: getHotkeyParts(value).map(formatKeyForDisplay));
diff --git a/src/interface/components/store/Backgrounds.svelte b/src/interface/components/store/Backgrounds.svelte
index 344bcfb1..80da352a 100644
--- a/src/interface/components/store/Backgrounds.svelte
+++ b/src/interface/components/store/Backgrounds.svelte
@@ -14,7 +14,6 @@
onCategoriesChange: (categories: string[]) => void;
}>();
- // Existing states
let backgrounds = $state([]);
let error = $state(null);
let selectedBackground = $state(null);
@@ -22,11 +21,9 @@
let savedBackgrounds = $state([]);
let installingBackgrounds = $state>(new Set());
let debugInfo = $state('');
- // New state variables
let activeTab = $state<'all' | 'installed' | 'photos' | 'videos'>('all');
let sortBy = $state<'newest' | 'popular' | 'name'>('newest');
- // Existing functions
const loadStore = async () => {
try {
debugInfo = 'Fetching backgrounds...';
@@ -60,10 +57,8 @@
}
}
- // Load data on mount
loadStore();
- // Derived states
let filteredBackgrounds = $derived((() => {
let filtered = backgrounds;
@@ -74,7 +69,6 @@
);
}
- // Apply category filtering
filtered = filtered.filter((bg: Background) => {
return selectedCategory === 'All'
? true
@@ -83,7 +77,6 @@
: bg.category === selectedCategory;
});
- // Apply sorting
filtered.sort((a: Background, b: Background) => {
switch (sortBy) {
case 'name':
@@ -101,7 +94,6 @@
})());
let categories = $derived([...new Set(backgrounds.map(bg => bg.category))]);
- // Background management functions
async function saveBackgroundFromUrl(url: string, id: string, fileType: string): Promise {
try {
if (!isIndexedDBSupported()) {
diff --git a/src/interface/hooks/BackgroundUpdates.ts b/src/interface/hooks/BackgroundUpdates.ts
index 7710a7c3..892695ae 100644
--- a/src/interface/hooks/BackgroundUpdates.ts
+++ b/src/interface/hooks/BackgroundUpdates.ts
@@ -1,40 +1,3 @@
-type BackgroundUpdateCallback = () => void;
+import { createUpdateSignal } from "./updateSignal";
-/**
- * A singleton class used to notify listeners about generic background updates or events.
- * These updates typically signify that UI components or other parts of the application
- * might need to refresh or re-evaluate background-related data (e.g., after a new background
- * image is added, removed, or changed).
- */
-class BackgroundUpdates {
- private static instance: BackgroundUpdates;
- private listeners: Set = new Set();
-
- private constructor() {}
-
- public static getInstance(): BackgroundUpdates {
- if (!BackgroundUpdates.instance) {
- BackgroundUpdates.instance = new BackgroundUpdates();
- }
- return BackgroundUpdates.instance;
- }
-
- public addListener(callback: BackgroundUpdateCallback): void {
- this.listeners.add(callback);
- }
-
- public removeListener(callback: BackgroundUpdateCallback): void {
- this.listeners.delete(callback);
- }
-
- /**
- * Invokes all registered listener callbacks, signifying that a background update has occurred.
- * This method should be called whenever a change to background data happens that requires
- * other parts of the application to be notified.
- */
- public triggerUpdate(): void {
- this.listeners.forEach((callback) => callback());
- }
-}
-
-export const backgroundUpdates = BackgroundUpdates.getInstance();
+export const backgroundUpdates = createUpdateSignal();
diff --git a/src/interface/hooks/ThemeUpdates.ts b/src/interface/hooks/ThemeUpdates.ts
index b6c60461..b74c9ded 100644
--- a/src/interface/hooks/ThemeUpdates.ts
+++ b/src/interface/hooks/ThemeUpdates.ts
@@ -1,40 +1,3 @@
-type ThemeUpdateCallback = () => void;
+import { createUpdateSignal } from "./updateSignal";
-/**
- * A singleton class used to notify listeners about theme-related updates.
- * These updates can include events like theme changes, custom theme modifications,
- * or any other event that might require UI components to refresh their appearance
- * or re-apply theme styles.
- */
-class ThemeUpdates {
- private static instance: ThemeUpdates;
- private listeners: Set = new Set();
-
- private constructor() {}
-
- public static getInstance(): ThemeUpdates {
- if (!ThemeUpdates.instance) {
- ThemeUpdates.instance = new ThemeUpdates();
- }
- return ThemeUpdates.instance;
- }
-
- public addListener(callback: ThemeUpdateCallback): void {
- this.listeners.add(callback);
- }
-
- public removeListener(callback: ThemeUpdateCallback): void {
- this.listeners.delete(callback);
- }
-
- /**
- * Invokes all registered listener callbacks, signifying that a theme-related update has occurred.
- * This method should be called whenever a change related to themes happens that requires
- * other parts of the application to be notified.
- */
- public triggerUpdate(): void {
- this.listeners.forEach((callback) => callback());
- }
-}
-
-export const themeUpdates = ThemeUpdates.getInstance();
+export const themeUpdates = createUpdateSignal();
diff --git a/src/interface/hooks/updateSignal.ts b/src/interface/hooks/updateSignal.ts
new file mode 100644
index 00000000..cc040c36
--- /dev/null
+++ b/src/interface/hooks/updateSignal.ts
@@ -0,0 +1,8 @@
+export function createUpdateSignal() {
+ const listeners = new Set<() => void>();
+ return {
+ addListener: (callback: () => void) => void listeners.add(callback),
+ removeListener: (callback: () => void) => void listeners.delete(callback),
+ triggerUpdate: () => listeners.forEach((callback) => callback()),
+ };
+}
diff --git a/src/interface/pages/settings/theme.svelte b/src/interface/pages/settings/theme.svelte
index b7ee799d..55d32fc8 100644
--- a/src/interface/pages/settings/theme.svelte
+++ b/src/interface/pages/settings/theme.svelte
@@ -8,7 +8,6 @@
section?: "all" | "themes" | "backgrounds";
}>();
- // backgrounds
let selectedBackground = $state(null);
let selectNoBackground = $state<() => void>(() => { });
diff --git a/src/interface/pages/store.svelte b/src/interface/pages/store.svelte
index b3d80f82..78f902ca 100644
--- a/src/interface/pages/store.svelte
+++ b/src/interface/pages/store.svelte
@@ -1,7 +1,6 @@