Alexa Fluor

Show

document.addEventListener("DOMContentLoaded", function () { function hideDuplicateSKU() { let skuElements = document.querySelectorAll(".stamped-main-widget [data-product-sku]"); console.log("SKU Elements Found:", skuElements.length); // Log the number of elements if (skuElements.length > 1) { skuElements.forEach((el, index) => { if (index > 0) { el.style.display = "none"; // Hide all but the first SKU console.log("Hiding SKU: ", el.getAttribute('data-product-sku')); } }); } else { console.log("No duplicates to hide."); } } // Run on initial page load hideDuplicateSKU(); // Use MutationObserver to watch for changes in the widget container (for variants) let observer = new MutationObserver(function (mutationsList) { mutationsList.forEach((mutation) => { if (mutation.type === "childList" || mutation.type === "subtree") { console.log("Mutation detected, checking SKUs..."); hideDuplicateSKU(); // Reapply fix on content changes (like variant switch) } }); }); let targetNode = document.querySelector(".stamped-main-widget"); if (targetNode) { observer.observe(targetNode, { childList: true, subtree: true }); console.log("MutationObserver started"); } else { console.log("Stamped widget not found."); } });