Код: Выделить всё
function callback(mutationList) {
console.log("Observer callback fired");
for (const mutation of mutationList) {
if (mutation.type === "childList") {
var cartDrawerBody = document.querySelector("div.cart-drawer__body");
if (cartDrawerBody) {
var children = cartDrawerBody.querySelectorAll(".cart-item__container").length;
if (children > 0) {
observer.disconnect(); // Disconnect the observer to prevent loop
adjustPadding();
var cartDrawerFooter = document.querySelector(".cart-drawer__footer");
if (!cartDrawerFooter) {
console.log("No footer found");
return;
}
if (!$(cartDrawerFooter).find(".post-footer-content").length) {
var postFooterContent = $(`
Content
`);
$(cartDrawerFooter).append(postFooterContent);
console.log("Content appended to footer");
} else {
console.log("Content already exists in footer, not appending");
}
observer.observe(document.querySelector("#cd-cart"), {
attributes: true,
childList: true,
subtree: true,
characterData: true,
});
} else {
console.log("no children to append");
}
} else {
console.log("no body");
}
}
}
}
var observer = new MutationObserver(callback);
observer.observe(cartDrawer, {
attributes: true,
childList: true,
subtree: true,
characterData: true,
});
Кто-нибудь сталкивался с проблемой подобная проблема или есть идеи, почему это может происходить? Будем очень признательны за любую помощь!
Спасибо!
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/785 ... ios-mobile
Мобильная версия