Gift Wrap
(function () {
const blockedSources = ['gpay', 'phonepe', 'paytm', 'cred', 'zepto', 'zomato', 'amazon'];
/* -------------------------------
Source Detection
--------------------------------*/
function hasBlockedInURL() {
const url = window.location.href.toLowerCase();
return blockedSources.some((source) => url.includes(source));
}
function hasBlockedInCookies() {
const cookies = document.cookie.toLowerCase();
return blockedSources.some((source) => cookies.includes(`cntl_utm_source=${source}`));
}
const shouldBlock = hasBlockedInURL() || hasBlockedInCookies();
if (!shouldBlock) return;
/* -------------------------------
Helpers
--------------------------------*/
function applyMargin(button) {
if (!button) return;
button.style.marginTop = window.matchMedia('(max-width: 749px)').matches ? '2px' : '3px';
}
function hideMainBestPriceBox() {
const mainBox = document.getElementById('best-price-main-box');
if (!mainBox) return;
mainBox.style.display = 'none';
}
function hideBestPriceBoxes() {
// Hide all small best price boxes
document.querySelectorAll('[id^="best-price-box"]').forEach((box) => {
box.style.display = 'none';
const productCard = box.closest('.card, .product-card, .grid__item') || document;
const quickAddBtn = productCard.querySelector('.quick-add__submit');
applyMargin(quickAddBtn);
});
// Hide main price box
hideMainBestPriceBox();
}
// Run once
hideBestPriceBoxes();
// Handle AJAX / dynamic content
const observer = new MutationObserver(hideBestPriceBoxes);
observer.observe(document.body, {
childList: true,
subtree: true,
});
})();