Narrowed trigger criteria

Instead of running every time document.head mutates, only run when mutation is an attribute change, target is a link, rel includes icon, and attribute is href.
This commit is contained in:
Jaxon Lewis-Wilson
2026-01-27 16:09:15 +08:00
parent 2c0f48877f
commit 2afe2364e4
+16 -4
View File
@@ -52,17 +52,29 @@ async function init() {
replaceIcons();
const observer = new MutationObserver(() => {
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, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ["href", "rel"],
attributeFilter: ["href"],
});
try {
await initializeSettingsState();