Created
January 1, 2025 21:42
-
-
Save barleybobs/ee56ea70f1a569c15dd8fb6eb208d458 to your computer and use it in GitHub Desktop.
JS to detect the Honey extensions popup on a checkout page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const honeyObserver = new MutationObserver((mutationsList) => { | |
for (const mutation of mutationsList) { | |
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) { | |
for (const node of mutation.addedNodes) { | |
if ( | |
node.nodeType === Node.ELEMENT_NODE && | |
node.tagName === "DIV" && | |
node.hasAttribute('data-reactroot') && | |
node.innerHTML === "<link href=\"https://cdn.honey.io/css/honey-font.min.css?v2\" rel=\"stylesheet\">" | |
) { | |
// Honey has been detected | |
} | |
} | |
} | |
} | |
}); | |
honeyObserver.observe(document, { | |
childList: true, | |
subtree: true, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment