document.addEventListener("DOMContentLoaded", function () { const isHome = window.location.pathname === "/" || window.location.pathname === ""; if (!isHome) return; const bannerData = [ "https://cdn.salla.sa/form-builder/1ssJzVJiY9TnKBSmF6NKNIVFu2wKpX1IMYj108QT.gif", "https://cdn.salla.sa/form-builder/biDA4ernE6uuo6Frmbz50LF9BUenflKEZLTyvT3o.gif", "https://cdn.salla.sa/form-builder/zT0nS5mNIBJXZajFbE780FL6kICRO5JOMdABJe2H.gif" ]; const targetLink = "https://crystalflms.com/عازل%20حراري%20للسيارات/c918870900"; // البنر الأول const bannerContainer = document.createElement("div"); bannerContainer.className = "full-banner-container"; const firstBanner = document.createElement("a"); firstBanner.href = targetLink; firstBanner.target = "_blank"; const firstImg = document.createElement("img"); firstImg.src = bannerData[0]; firstImg.alt = "Banner"; firstImg.classList.add("loaded"); firstBanner.appendChild(firstImg); bannerContainer.appendChild(firstBanner); const header = document.querySelector("header"); if (header?.parentNode) { header.parentNode.insertBefore(bannerContainer, header.nextSibling); } else { document.body.prepend(bannerContainer); } // قسم العازل الحراري const insulation = [ { name: "عازل نانو سيراميك للسيارات", link: "https://crystalflms.com/jgZOrYl", image: "https://cdn.salla.sa/ydVRKy/Jmvy4ckTIArMMP72JlCHmEwPZ6miOI476bussrnq.png", price: "349 ريال", oldPrice: "1299 ريال" }, { name: "عازل نانو للمباني", link: "https://crystalflms.com/eQPGpNv", image: "https://cdn.salla.sa/ydVRKy/ces63UDeDww62e8KJR6eMa2vSXuyBN9rPwhPZL2j.png", price: "65 ريال", oldPrice: "129 ريال" } ]; const insulationWrapper = document.createElement("div"); const insulationTitle = document.createElement("h2"); insulationTitle.className = "category-title"; insulationTitle.textContent = "العازل الحراري"; const insulationContainer = document.createElement("div"); insulationContainer.className = "product-section"; insulation.forEach(product => { const card = document.createElement("div"); card.className = "product-card"; card.innerHTML = ` ${product.name}

${product.name}

${product.oldPrice || ""}
${product.price}
عرض المنتج `; insulationContainer.appendChild(card); }); insulationWrapper.appendChild(insulationTitle); insulationWrapper.appendChild(insulationContainer); bannerContainer.insertAdjacentElement("afterend", insulationWrapper); // قسم العروض const offers = [ { name: "عازل نانو سيراميك ودرع زجاجي", link: "https://crystalflms.com/azejnmb", image: "https://cdn.salla.sa/ydVRKy/DS4jm11WYb155Y1p2CqYV7aDfUEWHJg28bQt6P4Z.png", price: "449 ريال", oldPrice: "799 ريال" }, { name: "2 عازل نانو سيراميك", link: "https://crystalflms.com/qGQxxgb", image: "https://cdn.salla.sa/ydVRKy/dC7M62wWlyw83YjnojhaHQMjAICtof1BlxQPdNJW.png", price: "599 ريال", oldPrice: "999 ريال" } ]; const offersWrapper = document.createElement("div"); const offersTitle = document.createElement("h2"); offersTitle.className = "category-title"; offersTitle.textContent = "العروض"; const offersContainer = document.createElement("div"); offersContainer.className = "product-section"; offers.forEach(product => { const card = document.createElement("div"); card.className = "product-card"; card.innerHTML = ` ${product.name}

${product.name}

${product.oldPrice || ""}
${product.price}
عرض المنتج `; offersContainer.appendChild(card); }); offersWrapper.appendChild(offersTitle); offersWrapper.appendChild(offersContainer); insulationWrapper.insertAdjacentElement("afterend", offersWrapper); // البنر الثاني const secondBannerContainer = document.createElement("div"); secondBannerContainer.className = "full-banner-container"; const secondBanner = document.createElement("a"); secondBanner.href = targetLink; secondBanner.target = "_blank"; const secondImg = document.createElement("img"); secondImg.src = bannerData[1]; secondImg.alt = "Banner"; secondImg.classList.add("loaded"); secondBanner.appendChild(secondImg); secondBannerContainer.appendChild(secondBanner); offersWrapper.insertAdjacentElement("afterend", secondBannerContainer); // قسم الحماية const protection = [ { name: "حماية هيكل السيارة PPF", link: "https://crystalflms.com/VDqQQRW", image: "https://cdn.salla.sa/ydVRKy/fYVUOjaDuXlHwLGx56lqKcUxmT9e9GEOH6bvOLin.png", price: "420 ريال", oldPrice: "699 ريال" }, { name: "الدرع الزجاجي - فلم حماية الزجاج", link: "https://crystalflms.com/BprVVwq", image: "https://cdn.salla.sa/ydVRKy/Upp0ayJu2N9Vc7sBCerRr3wQt4DyGzpJRWPtd9ro.png", price: "249 ريال", oldPrice: "399 ريال" } ]; const protectionWrapper = document.createElement("div"); const protectionTitle = document.createElement("h2"); protectionTitle.className = "category-title"; protectionTitle.textContent = "الحماية"; const protectionContainer = document.createElement("div"); protectionContainer.className = "product-section"; protection.forEach(product => { const card = document.createElement("div"); card.className = "product-card"; card.innerHTML = ` ${product.name}

${product.name}

${product.oldPrice || ""}
${product.price}
عرض المنتج `; protectionContainer.appendChild(card); }); protectionWrapper.appendChild(protectionTitle); protectionWrapper.appendChild(protectionContainer); secondBannerContainer.insertAdjacentElement("afterend", protectionWrapper); // البنر الثالث const thirdBannerContainer = document.createElement("div"); thirdBannerContainer.className = "full-banner-container"; const thirdBanner = document.createElement("a"); thirdBanner.href = targetLink; thirdBanner.target = "_blank"; const thirdImg = document.createElement("img"); thirdImg.src = bannerData[2]; thirdImg.alt = "Banner"; thirdImg.classList.add("loaded"); thirdBanner.appendChild(thirdImg); thirdBannerContainer.appendChild(thirdBanner); protectionWrapper.insertAdjacentElement("afterend", thirdBannerContainer); // قسم الإعلانات الترويجية بعد البنر الثالث const promoWrapper = document.createElement("div"); promoWrapper.className = "promo-section"; const promoImages = [ "https://cdn.salla.sa/form-builder/IihZN1IlxNa64dOoEj5Y86R57eMmrV0V1DAw4o7v.jpg", "https://cdn.salla.sa/form-builder/5Jolsya0K2IggEHw94p80ZsMDL5Prdm8cwrAvFFf.jpg", "https://cdn.salla.sa/form-builder/0TW5Dfjj6MvDaZZhXNM4JPeYDoWNflYFAmKqwsl3.png" ]; promoImages.forEach(src => { const promoImg = document.createElement("img"); promoImg.src = src; promoImg.alt = "إعلان ترويجي"; promoImg.className = "promo-banner"; promoWrapper.appendChild(promoImg); }); thirdBannerContainer.insertAdjacentElement("afterend", promoWrapper); }); function applyAccordion() { document.querySelectorAll("ul").forEach(function (ul) { if (ul.dataset.accordionApplied === "true") return; const lis = ul.querySelectorAll("li"); if (lis.length > 1 && lis[0].classList.contains("ql-align-center")) { const titleDiv = document.createElement("div"); titleDiv.className = "accordion-title"; titleDiv.innerHTML = lis[0].innerHTML; const contentDiv = document.createElement("div"); contentDiv.className = "accordion-content"; for (let i = 1; i < lis.length; i++) { contentDiv.appendChild(lis[i]); } const parent = ul.parentNode; parent.insertBefore(titleDiv, ul); parent.insertBefore(contentDiv, ul); ul.remove(); titleDiv.addEventListener("click", function () { contentDiv.style.display = contentDiv.style.display === "block" ? "none" : "block"; }); ul.dataset.accordionApplied = "true"; } }); } // تأخير التنفيذ حتى يتم تحميل المحتوى بشكل كامل window.addEventListener("load", function () { setTimeout(function () { applyAccordion(); }, 2000); // انتظر 2 ثانية قبل التنفيذ });