mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
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:
+16
-4
@@ -52,17 +52,29 @@ async function init() {
|
|||||||
|
|
||||||
replaceIcons();
|
replaceIcons();
|
||||||
|
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver((mutations) => {
|
||||||
replaceIcons();
|
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, {
|
observer.observe(document.head, {
|
||||||
childList: true,
|
|
||||||
subtree: true,
|
subtree: true,
|
||||||
attributes: true,
|
attributes: true,
|
||||||
attributeFilter: ["href", "rel"],
|
attributeFilter: ["href"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await initializeSettingsState();
|
await initializeSettingsState();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user