document.addEventListener("DOMContentLoaded", function () { // نحدد العنصر اللي عايزين نضيف بعده const targetElement = document.querySelector("body.product-single "); if (!targetElement) return; // لو مش موجود نوقف // ننشئ عنصر الـ section الجديد const newSection = document.createElement("section"); newSection.className = "animated-text animated-text--14 custom-ads-slider my-unique-banner"; newSection.style.backgroundColor = "#000000"; // المحتوى الداخلي للـ section newSection.innerHTML = `
`; // نضيف الـ section بعد العنصر مباشرة targetElement.insertAdjacentElement("afterend", newSection); }); //// (function () { // ========= القيم الخاصة بالمنتجات ========= const CUSTOM_VALUES = { "1108408333": 6000, "1006527051": 6500, "1108408331": 5000, "1108408332": 4000, "1108408313": 3000, "1259590888":2960, "1108408323": 2000, "1108408133": 1000 }; const DEFAULT_INCREMENT = 500; // القيمة الافتراضية لكل المنتجات الأخرى // ========= الحصول على ID المنتج من رابط الصفحة ========= const getProductId = () => { const match = window.location.href.match(/\/p(\d+)/); return match ? match[1] : null; }; // ========= تحديد قيمة الإضافة حسب المنتج ========= const getIncrementByProduct = (productId) => { if (!productId) return DEFAULT_INCREMENT; return CUSTOM_VALUES[productId] || DEFAULT_INCREMENT; }; // ========= تحديث البادج ========= const updateBadge = (badge) => { const countEl = badge.querySelector(".product-count-sale + span span"); if (!countEl || countEl.dataset.updated) return; const realNumber = Number(countEl.textContent.trim()); if (isNaN(realNumber)) return; const productId = getProductId(); if (!productId) return; const increment = getIncrementByProduct(productId); // 👀 نخفي الرقم قبل التعديل لتجنب ظهور الرقم القديم countEl.style.opacity = 0; countEl.textContent = realNumber + increment; countEl.dataset.updated = "true"; setTimeout(() => { countEl.style.transition = "opacity 0.3s"; countEl.style.opacity = 1; }, 50); }; // 🔍 إذا البادج موجود بالفعل document.querySelectorAll(".product-count-sale + span").forEach((el) => { updateBadge(el.parentElement); }); const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { mutation.addedNodes.forEach((node) => { if (node.nodeType === 1) { const badge = node.querySelector(".product-count-sale + span"); if (badge) updateBadge(badge.parentElement); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })();