/* Add custom Js styles below */ /* ================================= Footer ================================= */ document.addEventListener("DOMContentLoaded", function() { function buildMlehaFooter() { // جلب الوصف (موجود عندكِ سابقاً) const descElement = document.querySelector('.footer-description') || document.querySelector('.store-footer__inner p strong'); let storeDescHtml = descElement ? descElement.innerHTML : ""; // جلب اللغة والعملة const originalSettings = document.querySelector('.store-footer__settings'); const settingsHtml = originalSettings ? originalSettings.innerHTML : ""; // إذا كان النص فارغاً، نضع النص الافتراضي لمليحة if (!storeDescHtml || storeDescHtml.trim() === "") { storeDescHtml = ` قل للمليحة: في كل فستانٍ قصة… وفي كل تصميمٍ نخلق الجمال لأجلك
مليحة® علامة تجارية مسجلة
براند سعودي نفتخر به `; } const logoImg = document.querySelector('.store-footer__inner img.img-fluid'); const logoSrc = logoImg ? logoImg.src : "https://cdn.salla.sa/AzEboQ/fvTE4nMRp8E2TspQVyR6HYuaRnDIsiEelEnlruyT.png"; // 2. تحديث نصوص النشرة البريدية const newsH2 = document.querySelector('.store-footer__newsletter h2'); if (newsH2) newsH2.innerText = "اشتركي لتصلكِ تحديثات مليحة"; const newsContainer = document.querySelector('.store-footer__newsletter .container'); if (newsContainer && !document.querySelector('.mleha-sub-text')) { const subText = document.createElement('p'); subText.className = 'mleha-sub-text'; subText.innerText = "كوني أول من يطّلع على الإصدارات الجديدة، العروض الحصرية، وأحدث أخبار مليحة."; if (newsH2) newsH2.after(subText); } // 3. بناء الفوتر الجديد const footerInner = document.querySelector('.store-footer__inner'); if (footerInner && !document.querySelector('.mleha-custom-wrapper')) { const wrapper = document.createElement('div'); wrapper.className = 'mleha-custom-wrapper'; wrapper.innerHTML = `
Logo
${storeDescHtml}
وزارة التجارة
السجل التجاري 7005805622
الضريبة
الرقم الضريبي 311273037100003
المركز السعودي للأعمال
رقم التوثيق 0000173932
الملكية الفكرية
رقم العلامة التجارية TM-01-00-10719-25
|
`; // بدلاً من مسح كل شيء، نخفي العناصر القديمة فقط ونضيف الجديد const oldContainer = footerInner.querySelector('.container'); if (oldContainer) oldContainer.style.display = 'none'; footerInner.appendChild(wrapper); // تفعيل الأكورديون wrapper.querySelectorAll('.acc-item h3').forEach(header => { header.addEventListener('click', () => { if (window.innerWidth <= 768) header.parentElement.classList.toggle('active'); }); }); } } // تشغيل الوظيفة setTimeout(buildMlehaFooter, 500); // تأخير بسيط لضمان تحميل بيانات سلة }); /* ================================= Footer ================================= */ const header = document.querySelector('.main-nav-container'); window.addEventListener('scroll', () => { if (window.scrollY > 50) { header.style.setProperty('background-color', '#EFE3D6', 'important'); } else { header.style.setProperty('background-color', 'transparent', 'important'); } }); document.querySelectorAll('.s-block--custom-reviews h4').forEach(el => { if (el.textContent.includes(' - ')) { const [name, city] = el.textContent.split(' - '); el.innerHTML = ` ${name} ${city} `; } }); // Wait until the widget is loaded document.addEventListener("DOMContentLoaded", () => { const widget = document.querySelector("salla-mini-checkout-widget"); if (widget && widget.shadowRoot) { const button = widget.shadowRoot.querySelector("button"); if (button) { button.style.border = "none"; button.style.borderRadius = "8px"; button.style.fontSize = "14px"; } } }); function styleSallaButtons() { document.querySelectorAll('.s-fast-checkout-button').forEach(btn => { btn.style.border = 'none'; btn.style.borderRadius = '8px'; btn.style.fontSize = '14px'; }); } (function () { // Only on this product page var mustMatchPath = "/ar/oZEXQmz"; if (location.pathname !== mustMatchPath) return; // Add red style to .product-entry__sub-title var style = document.createElement("style"); style.textContent = ` .product-entry__sub-title { margin: 20px 0 0 0 !important; color: red !important; } .preorder-locked, .preorder-locked * { pointer-events: none !important; } .preorder-locked button, .preorder-locked [role="button"] { opacity: .5 !important; } `; document.head.appendChild(style); // Inject consent input after target

var h2 = document.querySelector('h2.product-entry__sub-title'); if (!h2) return; var consentBoxId = "preorder-consent-input"; if (!document.getElementById(consentBoxId)) { var consentWrapper = document.createElement("div"); consentWrapper.dir = "rtl"; consentWrapper.style.margin = "10px 0 16px"; consentWrapper.innerHTML = ` `; h2.insertAdjacentElement("afterend", consentWrapper); } var input = document.getElementById(consentBoxId); var containerSelector = ".s-add-product-button-main"; var consentOK = false; function getContainer() { return document.querySelector(containerSelector); } function hardLock() { var container = getContainer(); if (!container) return; container.classList.add("preorder-locked"); container.querySelectorAll("button,[role='button']").forEach(b => { b.setAttribute("disabled","disabled"); b.setAttribute("aria-disabled","true"); }); } function unlock() { consentOK = true; var container = getContainer(); if (!container) return; container.classList.remove("preorder-locked"); container.querySelectorAll("button,[role='button']").forEach(b => { b.removeAttribute("disabled"); b.setAttribute("aria-disabled","false"); b.style.pointerEvents = ""; b.style.opacity = ""; }); } hardLock(); var mo = new MutationObserver(() => { if (!consentOK) hardLock(); }); mo.observe(document.documentElement, { childList:true, subtree:true }); var watchdog = setInterval(() => { if (!consentOK) hardLock(); }, 300); function checkConsent() { var val = (input.value || "").trim(); if (val === "اوافق") { unlock(); clearInterval(watchdog); mo.disconnect(); } else { consentOK = false; hardLock(); } } ["input","change","paste"].forEach(evt => input.addEventListener(evt, checkConsent, {passive:true})); })(); (function() { var meta = document.querySelector('meta[name="theme-color"]'); if (!meta) { meta = document.createElement('meta'); meta.name = "theme-color"; document.head.appendChild(meta); } meta.setAttribute("content", "#9d3d38"); // meta.setAttribute("content", "#eee2d4"); })(); document.addEventListener("DOMContentLoaded", () => { const label = document.querySelector('.flex.justify-between.text-lg.mb-5 span.text-store-text-secondary'); if (label && label.textContent.trim() === "الإجمالي") { label.textContent = "الإجمالي (شامل الضريبة)"; } }); document.addEventListener("DOMContentLoaded", () => { document.querySelectorAll('.text-store-text-secondary').forEach(el => { if (el.textContent.includes("الأسعار شاملة للضريبة")) { el.remove(); } }); }); document.addEventListener("DOMContentLoaded", function () { document.querySelectorAll("*").forEach(function (el) { if (el.textContent.trim() === "السعر شامل الضريبه") { el.style.display = "none"; } }); }); document.addEventListener("DOMContentLoaded", () => { const DISMISS_KEY = "bcio_modal_dismissed_until"; // timestamp (ms) until which we won't show const AUTO_SHOW_DELAY_MS = 3000; // 3s after first scroll const isDismissed = () => { try { const v = localStorage.getItem(DISMISS_KEY); return v && Date.now() < Number(v); } catch { return false; } }; const dismissForToday = () => { try { const now = new Date(); const endOfDay = new Date(now); endOfDay.setHours(23, 59, 59, 999); // local end-of-day localStorage.setItem(DISMISS_KEY, String(endOfDay.getTime())); } catch {} }; if (isDismissed()) return; // ===== Container const container = document.createElement("div"); container.id = "bcio-popups"; container.style.cssText = "z-index:1000000;position:fixed;inset-block-start:0;inset-inline-start:0;"; document.body.appendChild(container); // ===== Overlay (CENTERED MODAL) const overlay = document.createElement("div"); overlay.setAttribute("data-testid", "bcio__popupRoot"); overlay.style.cssText = ` position: fixed; inset: 0; width: 100vw; height: 100vh; background-color: rgba(0,0,0,0.5); display: none; justify-content: center; align-items: center; direction: rtl; z-index: 1000002; `; const style = document.createElement("style"); style.innerHTML = `h1,h2,p{box-sizing:border-box;margin:0;padding:0}`; overlay.appendChild(style); const modal = document.createElement("div"); modal.style.cssText = ` display:flex; flex-direction:column-reverse; width:90%; height:382px; max-width:400px; background:#eeeeee; box-shadow:rgba(0,0,0,0.3) 0 2px 5px; position:relative; max-height:450px; border:none; border-radius:4px; align-items:stretch; justify-content:stretch; `; const closeBtn = document.createElementNS("http://www.w3.org/2000/svg", "svg"); closeBtn.setAttribute("width","18"); closeBtn.setAttribute("height","18"); closeBtn.setAttribute("viewBox","0 0 18 18"); closeBtn.setAttribute("role","button"); closeBtn.style.cssText = "position:absolute;inset-inline-end:1rem;top:1rem;cursor:pointer;"; closeBtn.innerHTML = ` `; const textArea = document.createElement("div"); textArea.style.cssText = ` flex:3 1 0%; text-align:center; display:flex; flex-direction:column; justify-content:center; align-items:center; padding:0 2em 2em 2em; gap:1em; `; textArea.innerHTML = `

يا هلا وغلا بالمليحة 💛

جهزّنا لك كود شحن مجاني على طلبك الأول 🎁

استخدميه قبل ما ينتهي 👇

احصل على كود الشحن المجاني

* بتعبئة هذا النموذج، ستقوم بالتسجيل لتلقي رسائلنا على الواتساب ويمكنك إلغاء الاشتراك في أي وقت.

`; const imageArea = document.createElement("div"); imageArea.style.cssText = `flex:2 1 0%; height:175px; display:block; overflow:hidden;`; const img = document.createElement("img"); img.src = "https://raw.githubusercontent.com/EmadAlareefi/mleha-font/refs/heads/main/images/discount-bg.jpg"; img.alt = "popup image"; img.loading = "lazy"; img.style.cssText = "width:100%;height:81%;object-fit:contain;background:#efe1d4;"; imageArea.appendChild(img); // assemble modal modal.appendChild(closeBtn); modal.appendChild(textArea); modal.appendChild(imageArea); overlay.appendChild(modal); container.appendChild(overlay); // Open / Close helpers const openModal = () => { if (isDismissed()) return; overlay.style.display = "flex"; }; const closeModal = () => { overlay.style.display = "none"; dismissForToday(); // don't show again today }; closeBtn.addEventListener("click", closeModal); // Clicking outside modal closes too overlay.addEventListener("click", (e) => { if (e.target === overlay) closeModal(); }); // ESC closes modal document.addEventListener("keydown", (e) => { if (e.key === "Escape" && overlay.style.display === "flex") { closeModal(); } }); // ===== Trigger: 3s AFTER FIRST SCROLL const scheduleOpen = () => { if (isDismissed()) return; setTimeout(openModal, AUTO_SHOW_DELAY_MS); }; // If already scrolled when loaded, schedule immediately; otherwise wait for first scroll if (window.scrollY > 0) { scheduleOpen(); } else { window.addEventListener("scroll", () => scheduleOpen(), { once: true, passive: true }); } }); document.addEventListener("DOMContentLoaded", () => { const socialLinks = [ { name: "Instagram", url: "https://www.instagram.com/mleha.sa/", svg: `` }, { name: "Snapchat", url: "https://www.snapchat.com/add/mleha.sa", svg: ` snapchat ` }, { name: "TikTok", url: "https://www.tiktok.com/@mleha.sa", svg: ` tiktok ` }, { name: "YouTube", url: "https://www.youtube.com/@mlehasa", svg: ` youtube [#168] Created with Sketch. ` } ]; const wrapper = document.querySelector('.s-social-share-wrapper'); if (!wrapper) return; const ul = wrapper.querySelector('.s-social-share-list') || document.createElement('ul'); ul.className = 's-social-share-list'; socialLinks.forEach(link => { const li = document.createElement('li'); const a = document.createElement('a'); a.href = link.url; a.target = "_blank"; a.rel = "nofollow noopener"; a.ariaLabel = `Visit us on ${link.name}`; a.className = "s-social-share-icon"; a.innerHTML = link.svg; li.appendChild(a); ul.appendChild(li); }); if (!wrapper.contains(ul)) { wrapper.appendChild(ul); } const button = document.querySelector('button.tab-trigger[data-target="details_table"]'); if (button) { const span = button.querySelector(".s-button-text"); if (span) { span.textContent = "وصف المنتج"; } } const allSpans = document.querySelectorAll('span'); let modelDiv = null; allSpans.forEach(span => { const text = span.textContent.trim(); if (text.includes('رمز الموديل') || text.includes('رقم الموديل')) { const parent = span.closest('.center-between'); if (parent) modelDiv = parent; } }); const stickySection = document.querySelector('.sticky-product-bar'); if (modelDiv && stickySection) { // Remove 'center-between' and apply new styles modelDiv.classList.remove('center-between'); modelDiv.style.marginTop = '12px'; modelDiv.style.gap = '10px'; modelDiv.style.display = 'flex'; modelDiv.style.justifyContent = 'flex-start'; modelDiv.style.alignItems = 'center'; // Append below sticky bar stickySection.appendChild(modelDiv); } }); document.addEventListener("DOMContentLoaded", function () { const footerText = document.querySelector(".footer-bottom p"); if (footerText) { footerText.innerHTML = '© جميع الحقوق محفوظة لعلامة “مليحة” التجارية. استخدام الصور دون إذن يُعرّضك للمساءلة القانونية'; } }); document.addEventListener("DOMContentLoaded", function () { const productForm = document.getElementById("product-form"); if (!productForm) return; // استخراج معرّف المنتج من آخر جزء في الرابط const urlParts = window.location.pathname.split("/").filter(Boolean); const productId = urlParts[urlParts.length - 1]; // p1930088709 const STORAGE_KEY = `product_viewers_count:${productId}`; const EXPIRY_MS = 2 * 60 * 1000; // دقيقتين let storedData = localStorage.getItem(STORAGE_KEY); let viewersCount; if (storedData) { try { storedData = JSON.parse(storedData); const now = Date.now(); if (now - storedData.timestamp < EXPIRY_MS) { viewersCount = storedData.count; } } catch (e) { // لو البيانات فاسدة تجاهلها } } if (!viewersCount) { viewersCount = Math.floor(Math.random() * (35 - 7 + 1)) + 7; // 7–35 localStorage.setItem( STORAGE_KEY, JSON.stringify({ count: viewersCount, timestamp: Date.now() }) ); } // إنشاء العنصر مع أيقونة العين const viewersBlock = document.createElement("div"); viewersBlock.className = "viewers-border"; viewersBlock.innerHTML = ` ${viewersCount} عملاء يشاهدون هذا المنتج الآن `; productForm.append(viewersBlock); }); document.addEventListener("DOMContentLoaded", function () { const originalColumn = document.querySelector(".store-links-items"); if (!originalColumn) return; // 1️⃣ Create a wrapper with two closer columns const wrapper = document.createElement("div"); wrapper.style.display = "grid"; wrapper.style.gridTemplateColumns = "auto auto"; // auto width to make them close wrapper.style.justifyContent = "center"; // center the columns wrapper.style.gap = "40px"; // reduce spacing between columns wrapper.style.textAlign = "center"; // Replace the original container parent content with the wrapper const parent = originalColumn.parentElement; parent.innerHTML = ""; parent.appendChild(wrapper); // 2️⃣ Create first column (روابط مهمة) const importantCol = document.createElement("div"); const importantTitle = document.createElement("h3"); importantTitle.textContent = "روابط مهمة"; importantTitle.style.marginBottom = "10px"; importantCol.appendChild(importantTitle); const importantList = document.createElement("ul"); importantList.className = "footer-list store-links-items"; importantList.style.textAlign = "center"; importantCol.appendChild(importantList); // 3️⃣ Create second column (روابط سريعة) const quickCol = document.createElement("div"); const quickTitle = document.createElement("h3"); quickTitle.textContent = "روابط سريعة"; quickTitle.style.marginBottom = "10px"; quickCol.appendChild(quickTitle); const quickList = document.createElement("ul"); quickList.className = "footer-list store-links-items"; quickList.style.textAlign = "center"; quickCol.appendChild(quickList); // 4️⃣ Move links const links = originalColumn.querySelectorAll("li a"); links.forEach(link => { const text = link.textContent.trim(); // Decide which column to move the link to if ( text.includes("الاستبدال") || text.includes("الخصوصية") || text.includes("الاستخدام") || text.includes("الشحن") ) { importantList.appendChild(link.parentElement); } else { quickList.appendChild(link.parentElement); } }); // 5️⃣ Append the columns to the wrapper wrapper.appendChild(importantCol); wrapper.appendChild(quickCol); }); document.addEventListener("DOMContentLoaded", function () { // Array of swipers with their links const swipers = [ { id: "featured-products-style2-2", link: "/ar/فساتين-سهرة/c86491111" }, { id: "featured-products-style2-6", link: "/ar/فساتين-نواعم/c1460461280" }, { id: "featured-products-style2-5", link: "/ar/جلابيات/c511204076" } ]; swipers.forEach(swiper => { const section = document.getElementById(swiper.id); if (section) { // Create wrapper const btnWrapper = document.createElement("div"); btnWrapper.style.textAlign = "center"; btnWrapper.style.marginTop = "30px"; // Create button const browseBtn = document.createElement("a"); browseBtn.textContent = "تصفح المزيد"; browseBtn.href = swiper.link; browseBtn.style.display = "inline-block"; browseBtn.style.padding = "8px 16px"; browseBtn.style.backgroundColor = "#f1edeb"; browseBtn.style.color = "rgb(119, 119, 119)"; browseBtn.style.fontWeight = "bold"; browseBtn.style.borderRadius = "8px"; browseBtn.style.textDecoration = "none"; browseBtn.style.fontSize = "18px"; browseBtn.style.transition = "0.3s"; // Hover effect browseBtn.addEventListener("mouseenter", () => { browseBtn.style.opacity = "0.85"; }); browseBtn.addEventListener("mouseleave", () => { browseBtn.style.opacity = "1"; }); // Append button under the swiper btnWrapper.appendChild(browseBtn); section.appendChild(btnWrapper); } }); }); (function () { const OUT_OF_STOCK_REGEX = /\s*[-–—|/•·]?\s*(?:نف(?:ذ|د)ت?\s*الكمية|غير\s*متوفر(?:ة)?|Out\s*of\s*stock)\s*/giu; function stripOutOfStockText() { document .querySelectorAll('.s-product-options-disabled .s-product-options-grid-mode-span:not([data-stripped])') .forEach(el => { const original = el.textContent || ""; const cleaned = original.replace(OUT_OF_STOCK_REGEX, '').trim(); if (cleaned && cleaned !== original.trim()) { el.textContent = cleaned; // أبقي الحجم فقط (S, M, L…) } el.dataset.stripped = '1'; // حتى لا نكرّر المعالجة }); } // شغّل عند تحميل الصفحة if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', stripOutOfStockText); } else { stripOutOfStockText(); } // راقب أي تغييرات (في حال السواتش تتحدّث آجاكس) const obs = new MutationObserver(stripOutOfStockText); obs.observe(document.documentElement, { childList: true, subtree: true }); })(); document.addEventListener("DOMContentLoaded", () => { // امسك عنصر "رقم الموديل" const modelRow = document.querySelector('.center-between.pb-5.mb-5.border-b-\\[1px\\]'); // امسك عنصر .viewers-border const viewersBorder = document.querySelector('.viewers-border'); if (modelRow && viewersBorder) { // انقل رقم الموديل بعد .viewers-border مباشرة viewersBorder.insertAdjacentElement("afterend", modelRow); // اضف مسافة فوق 10px modelRow.style.marginTop = "10px"; } }); (function () { // --- Config --- const MESSAGES = [ "🇸🇦✨ بمناسبة اليوم الوطني نتحدى الكل ✨🇸🇦", "👗 اختاري ٢ فساتين بـ ٩٥ ريال شامل الضريبة", "🚚 شحن مجاني لجميع الطلبات فوق ٣٩٩ ريال", "🎁 باكج فاخر هدية مع كل شحنة مجانية", "💚 ومو بس كذا… لك كود خصم خاص", ]; const TOTAL_MS = 3500; // المدة الإجمالية لكل رسالة const FADE_MS = 300; // مدة التلاشي const HOLD_MS = TOTAL_MS - FADE_MS; // زمن الثبات المرئي const FIXED = true; // true = ثابت أعلى الصفحة مع التمرير function ready(fn){ document.readyState!=="loading" ? fn() : document.addEventListener("DOMContentLoaded", fn); } ready(function(){ // Inject CSS const css = ` #promo-topbar{ display:none; position:${FIXED?'fixed':'sticky'}; top:0; left:0; right:0; z-index:30; background:#9d3d38; color:#fff; text-align:center; padding:.6rem .8rem; font-size:15px; line-height:1.4; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; ${FIXED?'width:100%;':''} } #promo-topbar .promo-text{ opacity:0; transition:opacity ${FADE_MS}ms ease; display:inline-block; } #promo-topbar .promo-text.show{ opacity:1; } @media (prefers-reduced-motion: reduce){ #promo-topbar .promo-text{ transition:none; } } `.trim(); const style = document.createElement("style"); style.textContent = css; document.head.appendChild(style); // Create bar const bar = document.createElement("div"); bar.id = "promo-topbar"; bar.setAttribute("role","status"); bar.setAttribute("aria-live","polite"); bar.setAttribute("dir","rtl"); const span = document.createElement("span"); span.className = "promo-text"; bar.appendChild(span); // Push page content down if fixed if (FIXED) { // temporarily attach to measure height, then add padding to body document.body.prepend(bar); requestAnimationFrame(()=>{ const h = bar.getBoundingClientRect().height; document.body.style.paddingTop = (parseFloat(getComputedStyle(document.body).paddingTop||"0")+h)+"px"; }); } else { document.body.prepend(bar); } // Rotation logic let i = 0; let reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches; function cycle(){ span.textContent = MESSAGES[i]; if (!reduceMotion) { // fade in span.classList.add("show"); setTimeout(()=>{ // fade out span.classList.remove("show"); setTimeout(()=>{ i = (i+1) % MESSAGES.length; cycle(); }, FADE_MS); }, HOLD_MS); } else { // no animation, plain swap every 2s span.classList.add("show"); setTimeout(()=>{ i = (i+1) % MESSAGES.length; cycle(); }, TOTAL_MS); } } cycle(); }); })(); // Run only on the cart page if (location.href.startsWith("https://mleha.com/ar/cart")) { (function () { const SUBTOTAL_THRESHOLD = 346.95; // = 399 incl. VAT const PRODUCT_OPTIONS_SELECTOR = 'salla-product-options[product-id="3014694887033630745"]'; const BADGE_ID = "ml-free-box-badge"; // ===== Styles ===== const style = document.createElement("style"); style.textContent = ` #${BADGE_ID} { display: flex; align-items: center; gap: 10px; background: #f9f5f5; border: 1px solid #f0d9d8; color: #9d3d38; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; font-weight: 700; direction: rtl; box-shadow: 0 6px 14px rgba(0,0,0,0.06); transform: translateY(0); transition: transform .2s ease, opacity .2s ease; opacity: 1; } #${BADGE_ID}.is-hidden { opacity: 0; transform: translateY(-4px); } #${BADGE_ID} .icon { width: 22px; height: 22px; border-radius: 6px; background: #9d3d38; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex: 0 0 22px; } #${BADGE_ID} .text { line-height: 1.35; } #${BADGE_ID} .hl { background: #9d3d38; color: #fff; padding: 2px 6px; border-radius: 8px; margin: 0 2px; } #${BADGE_ID} .sub { font-weight: 600; opacity: .9; font-size: 12px; display:block; margin-top:2px;} `; document.head.appendChild(style); // ===== Helpers ===== const parsePrice = (txt) => { if (!txt) return NaN; let s = txt.replace(/[^\d,.\-]/g, ""); if (/,/.test(s) && /\,\d{1,2}$/.test(s)) s = s.replace(/\./g, "").replace(",", "."); else s = s.replace(/,/g, ""); const v = parseFloat(s); return isNaN(v) ? NaN : v; }; function findSubtotalEl() { const candidates = [ '[data-cart-subtotal]', '.summary__subtotal .price', '.cart-summary .subtotal .price', '.cart-summary [data-value="subtotal"]', '.s-cart-summary [data-price]', '.cart__summary .price', '[data-cart-total]' ]; for (const sel of candidates) { const el = document.querySelector(sel); if (el && /\d/.test(el.textContent)) return el; } return null; } function getSubtotal() { const el = findSubtotalEl(); return el ? parsePrice(el.textContent) : NaN; } function getOptionsContainer() { const opts = document.querySelector(PRODUCT_OPTIONS_SELECTOR); if (!opts) return null; return ( opts.querySelector(".s-product-options-option-container") || opts.querySelector(".s-product-options-wrapper") || opts ); } function removeDupesKeepOne() { const all = Array.from(document.querySelectorAll(`#${BADGE_ID}`)); if (all.length <= 1) return; all.slice(1).forEach(n => n.remove()); } function ensureUI(meets) { const container = getOptionsContainer(); if (!container) return; removeDupesKeepOne(); let badge = document.getElementById(BADGE_ID); if (meets) { // Hide options container.style.display = "none"; if (!badge) { badge = document.createElement("div"); badge.id = BADGE_ID; badge.className = "is-hidden"; badge.innerHTML = ` صندوق التغليف الفاخر مجّاني مع طلبك المجموع وصل إلى٣٩٩ (شامل الضريبة) أو أكثر `; container.parentNode.prepend(badge); requestAnimationFrame(() => badge.classList.remove("is-hidden")); } else { badge.classList.remove("is-hidden"); } } else { // Show options back container.style.display = ""; if (badge) { badge.classList.add("is-hidden"); setTimeout(() => { const b = document.getElementById(BADGE_ID); if (b) b.remove(); }, 200); } } removeDupesKeepOne(); } function refresh() { const subtotal = getSubtotal(); if (isNaN(subtotal)) return; const meets = subtotal + 0.001 >= SUBTOTAL_THRESHOLD; ensureUI(meets); } refresh(); const observer = new MutationObserver(() => { clearTimeout(refresh._t); refresh._t = setTimeout(refresh, 120); }); observer.observe(document.body, { childList: true, subtree: true, characterData: true }); setTimeout(refresh, 600); setTimeout(refresh, 1500); })(); } document.querySelectorAll('section.animated-text .animated-text__inner ul').forEach(ul => { const firstItem = ul.querySelector('li'); if (firstItem) { ul.innerHTML = ''; ul.appendChild(firstItem); } }); // 2️⃣ عند تحميل الصفحة، اترك فقط النص الأول وأظهره document.addEventListener("DOMContentLoaded", function() { document.querySelectorAll('section.animated-text .animated-text__inner ul').forEach(ul => { const firstItem = ul.querySelector('li'); if (firstItem) { ul.innerHTML = ''; ul.appendChild(firstItem); // أضف النص الأول فقط firstItem.style.display = "block"; // أظهره } }); });