mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +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:
+15
-3
@@ -52,17 +52,29 @@ async function init() {
|
||||
|
||||
replaceIcons();
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user