document.addEventListener("DOMContentLoaded", function () { const container = document.querySelector( ".cat-square-banner .container" ); if (!container) return; // إنشاء العناصر const box = document.createElement("div"); box.className = "countdown-box"; const title = document.createElement("div"); title.className = "countdown-title"; title.textContent = "⏳ عروض الشتاء تنتهي خلال"; const timer = document.createElement("div"); timer.className = "countdown-timer"; const units = [ { id: "days", label: "يوم" }, { id: "hours", label: "ساعة" }, { id: "minutes", label: "دقيقة" }, { id: "seconds", label: "ثانية" } ]; units.forEach(unit => { const timeBox = document.createElement("div"); timeBox.className = "time-box"; const value = document.createElement("span"); value.id = unit.id; value.textContent = "00"; const label = document.createElement("small"); label.textContent = unit.label; timeBox.appendChild(value); timeBox.appendChild(label); timer.appendChild(timeBox); }); box.appendChild(title); box.appendChild(timer); // إدراج المستطيل في بداية القسم container.prepend(box); // تاريخ نهاية العرض (عدّله حسب حاجتك) const endDate = new Date("2025-12-31T23:59:59").getTime(); setInterval(() => { const now = new Date().getTime(); const diff = endDate - now; if (diff <= 0) { timer.textContent = "انتهى العرض"; return; } const days = Math.floor(diff / (1000 * 60 * 60 * 24)); const hours = Math.floor((diff / (1000 * 60 * 60)) % 24); const minutes = Math.floor((diff / (1000 * 60)) % 60); const seconds = Math.floor((diff / 1000) % 60); document.getElementById("days").textContent = days; document.getElementById("hours").textContent = hours; document.getElementById("minutes").textContent = minutes; document.getElementById("seconds").textContent = seconds; }, 1000); }); document.addEventListener("DOMContentLoaded", function () { const sliderContainer = document.querySelector(".s-block--photos-slider .container"); if (!sliderContainer) return; const banner = document.createElement("div"); banner.className = "winter-offer-banner"; banner.innerHTML = ` تسوق الآن `; sliderContainer.appendChild(banner); const copyBtn = banner.querySelector(".copy-btn"); const offerCode = banner.querySelector(".offer-code").textContent; const notice = banner.querySelector(".copy-notice"); copyBtn.addEventListener("click", () => { navigator.clipboard.writeText(offerCode).then(() => { // عرض الرسالة القصيرة notice.style.display = "inline"; setTimeout(() => { notice.style.display = "none"; }, 1500); // تختفي بعد 1.5 ثانية }); }); });