Skip to content

Instantly share code, notes, and snippets.

@barleybobs
Created January 1, 2025 21:42
Show Gist options
  • Save barleybobs/ee56ea70f1a569c15dd8fb6eb208d458 to your computer and use it in GitHub Desktop.
Save barleybobs/ee56ea70f1a569c15dd8fb6eb208d458 to your computer and use it in GitHub Desktop.
JS to detect the Honey extensions popup on a checkout page
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