feat: cleanup work on plugins system

This commit is contained in:
SethBurkart123
2025-03-17 15:06:26 +11:00
parent 75446c6855
commit 5c0044a4d4
6 changed files with 59 additions and 93 deletions
+49
View File
@@ -0,0 +1,49 @@
// Third-party libraries
import browser from "webextension-polyfill"
// Internal utilities and functions
import {
initializeSettingsState,
settingsState,
} from "@/seqta/utils/listeners/SettingsState"
// UI and theme management
import pageState from "@/pageState.js?url"
// Stylesheets
import injectedCSS from "@/css/injected.scss?inline"
export async function main() {
return new Promise(async (resolve, reject) => {
try {
await initializeSettingsState()
if (settingsState.onoff) {
injectPageState()
if (typeof settingsState.assessmentsAverage == "undefined") {
settingsState.assessmentsAverage = true
}
// TEMP FIX for bug! -> this is a hack to get the injected.css file to have HMR in development mode as this import system is currently broken with crxjs
if (import.meta.env.MODE === "development") {
import("../css/injected.scss")
} else {
const injectedStyle = document.createElement("style")
injectedStyle.textContent = injectedCSS
document.head.appendChild(injectedStyle)
}
}
resolve(true)
} catch (error: any) {
console.error(error)
reject(error)
}
})
}
function injectPageState() {
const mainScript = document.createElement("script")
mainScript.src = browser.runtime.getURL(pageState)
document.head.appendChild(mainScript)
}