try{
var dom_to_check = document.querySelector('.catalog-product-view .product-add-form .check-availability');
// Set up the MutationObserver
checkOOSStatus();//page load
var observer = new MutationObserver(function(){
console.log("callback that runs when observer is triggered " + Date.now());
setTimeout(checkOOSStatus(),1200);
//console.log("mutation obs dk - " + dom_to_check.textContent);
});
// Start observing the document with configured parameters
observer.observe(dom_to_check, {
childList: true, // Observe direct children
subtree: true, // And all descendants
attributes: true, // Observe attribute changes, as visibility could be controlled by inline styles
characterData: true,
});
} catch(e) {
console.error(e);
}
Simple MutationObserver for OOS Check
by
Tags: