document.addEventListener("DOMContentLoaded", function () {
// Function to add h1 tags to product titles
function addH1ToProductTitles() {
// Check if we are on a product page
const productTitleElement = document.querySelector(".ecwid-productBrowser-headline");
if (productTitleElement) {
// Check if an h1 tag already exists to avoid duplication
if (!productTitleElement.closest("h1")) {
// Wrap the product title in an h1 tag
const h1 = document.createElement("h1");
h1.textContent = productTitleElement.textContent;
productTitleElement.parentNode.replaceChild(h1, productTitleElement);
}
}
}
// Run the function when the page is loaded or updated dynamically
const ecwidObserver = new MutationObserver(() => {
addH1ToProductTitles();
});
// Start observing changes in the Ecwid product browser
ecwidObserver.observe(document.body, {
childList: true,
subtree: true,
});
// Initial call for already loaded content
addH1ToProductTitles();
});