From da68d752e358bae1531c4f20696d8c5515ce500c Mon Sep 17 00:00:00 2001 From: Greg Zajac Date: Mon, 29 Jan 2024 18:51:39 +0100 Subject: [PATCH] #1480 MutationObserver FIX --- .../observerConstants/notObservedNodes.js | 1 + .../observer/observerFunctions/addedNodes.js | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/content/observer/observerConstants/notObservedNodes.js b/src/content/observer/observerConstants/notObservedNodes.js index 873e29f..91acbc6 100644 --- a/src/content/observer/observerConstants/notObservedNodes.js +++ b/src/content/observer/observerConstants/notObservedNodes.js @@ -22,6 +22,7 @@ const notObservedNodes = [ 'path', 'body', 'head', + 'link', 'style', 'script', 'title', diff --git a/src/content/observer/observerFunctions/addedNodes.js b/src/content/observer/observerFunctions/addedNodes.js index 8e62336..f8e83e8 100644 --- a/src/content/observer/observerFunctions/addedNodes.js +++ b/src/content/observer/observerFunctions/addedNodes.js @@ -30,17 +30,14 @@ const addedNodes = (mutation, tabData) => { let newInputs = false; let inputs = []; - const addedNodes = Array.from(mutation?.addedNodes); + + const addedNodes = Array.from(mutation?.addedNodes).filter(node => !notObservedNodes.includes(node.nodeName.toLowerCase())); if (!addedNodes || addedNodes.length <= 0) { return false; } for (const node in addedNodes) { - if (notObservedNodes.includes(addedNodes[node].nodeName.toLowerCase())) { - break; - } - if (findSignificantChanges(addedNodes[node])) { newInputs = true; } @@ -48,15 +45,13 @@ const addedNodes = (mutation, tabData) => { if (!newInputs) { for (const node in addedNodes) { - if (notObservedNodes.includes(addedNodes[node].nodeName.toLowerCase())) { - break; - } - - inputs.concat(getInputs(addedNodes[node])); + inputs.push(...getInputs(addedNodes[node])); } inputs = inputs.filter(node => !node.hasAttribute('data-twofas-input')); newInputs = inputs.length > 0; + } else { + inputs = getInputs(); } if (newInputs) {