diff --git a/src/SEQTA.ts b/src/SEQTA.ts index e64cd716..d94c7b71 100644 --- a/src/SEQTA.ts +++ b/src/SEQTA.ts @@ -30,15 +30,34 @@ async function init() { IsSEQTAPage = true; console.info("[BetterSEQTA+] Verified SEQTA Page"); - const style = document.createElement("style"); - style.textContent = documentLoadCSS; - document.head.appendChild(style); + const documentLoadStyle = document.createElement("style"); + documentLoadStyle.textContent = documentLoadCSS; + document.head.appendChild(documentLoadStyle); + + replaceIcons(); + + const observer = new MutationObserver((mutations) => { + for (const mutation of mutations) { + + if ( + mutation.type === "attributes" && + mutation.target instanceof HTMLLinkElement && + mutation.target.rel.includes("icon") && + mutation.attributeName === "href" + ) { + replaceIcons(); + return; + } + } + }); + + observer.observe(document.head, { + subtree: true, + attributes: true, + attributeFilter: ["href"], + }); + - document - .querySelectorAll('link[rel*="icon"]') - .forEach((link) => { - link.href = icon48; - }); try { await initializeSettingsState(); @@ -68,3 +87,13 @@ async function init() { } } } + +function replaceIcons() { + document + .querySelectorAll('link[rel*="icon"]') + .forEach((link) => { + if (link.href !== icon48) { + link.href = icon48; + } + }); +} \ No newline at end of file