fix
Some checks failed
Deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-04-27 09:06:48 -06:00
parent 96f6be8dbe
commit 569a475fef

View File

@@ -2,6 +2,7 @@ import { ref } from "vue"
import { getMaxkb, postMaxkb } from "../api" import { getMaxkb, postMaxkb } from "../api"
const enabled = ref(true) const enabled = ref(true)
let observer: MutationObserver | null = null
function applyState() { function applyState() {
document.querySelectorAll<HTMLElement>("body > [id^='maxkb-']").forEach(el => { document.querySelectorAll<HTMLElement>("body > [id^='maxkb-']").forEach(el => {
@@ -9,6 +10,14 @@ function applyState() {
}) })
} }
function startObserver() {
if (observer) return
observer = new MutationObserver(() => {
if (!enabled.value) applyState()
})
observer.observe(document.body, { childList: true })
}
export async function fetchMaxkbState() { export async function fetchMaxkbState() {
try { try {
const res = await getMaxkb() const res = await getMaxkb()
@@ -26,5 +35,6 @@ export async function toggleMaxkb() {
} }
export function initMaxkb() { export function initMaxkb() {
startObserver()
fetchMaxkbState() fetchMaxkbState()
} }