diff --git a/src/SEQTA.ts b/src/SEQTA.ts index 9d4dc8c7..70773ca1 100644 --- a/src/SEQTA.ts +++ b/src/SEQTA.ts @@ -50,13 +50,31 @@ async function init() { documentLoadStyle.textContent = documentLoadCSS; document.head.appendChild(documentLoadStyle); - const icons = - document.querySelectorAll('link[rel*="icon"]'); + replaceIcons(); - icons.forEach((link) => { - link.href = icon48; + 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"], + }); + + + try { await initializeSettingsState(); @@ -85,3 +103,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