/* ========================================================= WENBEL STORE — MASTER JAVASCRIPT V3 ========================================================= */ (function () { "use strict"; /* ===================================================== HELPERS ===================================================== */ function cleanText(el) { return (el && el.textContent ? el.textContent : "") .replace(/\s+/g, " ") .trim(); } function isHomePage() { var path = window.location.pathname .replace(/\/+$/, ""); return path === ""; } /* ===================================================== 1. GLOBAL FOOTER ===================================================== */ function buildWenbelFooter() { var footer = document.createElement("section"); footer.id = "wenbel-global-footer"; footer.dir = "rtl"; footer.innerHTML = `
ونبل ستور

متجر سعودي للمنتجات الرقمية، نوفر اشتراكات وتراخيص وأكواد رقمية مع توضيح تفاصيل كل منتج قبل إتمام الطلب.

سلة salla
متجر موثّق موثّق لدى سلة
العمل الحر
وثيقة العمل الحر FL-682141835

وسائل الدفع

VISA Mastercard ● Pay مدى mada stc pay PayPal
© ونبل ستور — جميع الحقوق محفوظة. متجر منتجات رقمية
`; return footer; } function findNativeFooter() { return ( document.querySelector("footer.store-footer") || document.querySelector(".store-footer") || document.querySelector("body > footer") || document.querySelector("footer") ); } function installGlobalFooter() { var homeFooter = document.querySelector(".wb-footer-pro"); /* * الرئيسية لديها الفوتر الخاص بها. */ if (isHomePage() || homeFooter) { var injected = document.getElementById( "wenbel-global-footer" ); if (injected) { injected.remove(); } return; } var nativeFooter = findNativeFooter(); if (!nativeFooter) return; var customFooter = document.getElementById( "wenbel-global-footer" ); if (!customFooter) { customFooter = buildWenbelFooter(); nativeFooter.insertAdjacentElement( "beforebegin", customFooter ); } nativeFooter.style.setProperty( "display", "none", "important" ); } /* ===================================================== 2. KEEP FOOTER LAST يعالج "اطلبها مجدداً" إذا حملته سلة بعد الفوتر ===================================================== */ function findReorderSection() { var headings = document.querySelectorAll( "h1, h2, h3, h4, [class*='title']" ); for ( var i = 0; i < headings.length; i++ ) { var text = cleanText(headings[i]); if ( text.includes("اطلبها مجددا") || text.includes("اطلبها مجددًا") ) { return ( headings[i].closest("section") || headings[i].closest( "salla-products-slider" ) || headings[i].parentElement ?.parentElement || null ); } } return null; } function keepFooterLast() { /* * الرئيسية: * الفوتر الموجود عندك هو wb-footer-pro. */ var homeFooter = document.querySelector(".wb-footer-pro"); if (homeFooter) { var reorderHome = findReorderSection(); if ( reorderHome && reorderHome !== homeFooter ) { /* * إذا كان "اطلبها مجدداً" بعد الفوتر، * ننقله مباشرة قبله. */ var position = homeFooter.compareDocumentPosition( reorderHome ); if ( position & Node.DOCUMENT_POSITION_FOLLOWING ) { homeFooter.parentNode .insertBefore( reorderHome, homeFooter ); } } return; } /* * الصفحات الأخرى: * الفوتر المخصص. */ var globalFooter = document.getElementById( "wenbel-global-footer" ); if (!globalFooter) return; var reorder = findReorderSection(); if ( reorder && reorder !== globalFooter ) { var relation = globalFooter.compareDocumentPosition( reorder ); if ( relation & Node.DOCUMENT_POSITION_FOLLOWING ) { globalFooter.parentNode .insertBefore( reorder, globalFooter ); } } } /* ===================================================== 3. PRODUCT TRUST BAR ===================================================== */ function findSoldElement() { var elements = Array.from( document.querySelectorAll( "div, span, p" ) ); return elements.find( function (el) { var text = cleanText(el); return ( /تم\s*شراؤه/.test(text) && /مرة/.test(text) && /[0-9٠-٩]/.test(text) && text.length < 80 ); } ); } function getSoldCount( soldElement ) { if (!soldElement) { return ""; } var match = cleanText(soldElement) .match( /[0-9٠-٩٬,]+/ ); return match ? match[0] : ""; } function findProductGallery() { return ( document.querySelector( "salla-slider[type='thumbs']" ) || document.querySelector( ".product-gallery" ) || document.querySelector( ".product-slider" ) || document.querySelector( ".product-image-container" ) ); } function findProductPriceBox() { var elements = Array.from( document.querySelectorAll( "div, section" ) ); return elements.find( function (el) { var text = cleanText(el); return ( text.includes("السعر") && /[0-9٠-٩]/.test(text) && el.children.length <= 10 ); } ); } function isProductPage() { var gallery = findProductGallery(); var priceBox = findProductPriceBox(); /* * معرض + سعر = صفحة منتج. * لا نعتمد على ظهور زر السلة، * لأن بعض المنتجات قد يتأخر تحميله. */ return !!( gallery && priceBox ); } function buildProductTrust( soldCount ) { var trust = document.createElement("div"); trust.id = "wenbel-product-trust"; var salesHTML = soldCount ? ` ${soldCount} عملية شراء ` : ` عمليات الشراء بيانات المنتج `; trust.innerHTML = `
${salesHTML}
تقييمات المنتج آراء عملاء موثقة
`; return trust; } function installProductTrust() { if (!isProductPage()) { /* * مهم عند التنقل داخل سلة بدون Reload. */ var stale = document.getElementById( "wenbel-product-trust" ); if (stale) { stale.remove(); } return; } var soldElement = findSoldElement(); var soldCount = getSoldCount( soldElement ); var existing = document.getElementById( "wenbel-product-trust" ); if (existing) { var salesContent = existing.querySelector( ".wb-product-stat:first-child .wb-stat-content" ); if (salesContent) { if (soldCount) { salesContent.innerHTML = ` ${soldCount} عملية شراء `; } else { salesContent.innerHTML = ` عمليات الشراء بيانات المنتج `; } } if (soldElement) { soldElement.style .setProperty( "display", "none", "important" ); } return; } var trust = buildProductTrust( soldCount ); var gallery = findProductGallery(); var priceBox = findProductPriceBox(); if (gallery) { gallery.insertAdjacentElement( "afterend", trust ); } else if (priceBox) { priceBox.insertAdjacentElement( "afterend", trust ); } else { return; } if (soldElement) { soldElement.style .setProperty( "display", "none", "important" ); } } /* ===================================================== 4. HIDE "منتجات قد تعجبك" ===================================================== */ function hideSuggestedProducts() { var headings = document.querySelectorAll( "h1, h2, h3, h4, .section-title, [class*='title']" ); headings.forEach( function (heading) { var text = cleanText(heading); if ( text !== "منتجات قد تعجبك" ) { return; } var section = heading.closest( "section" ) || heading.closest( "salla-products-slider" ) || heading.parentElement ?.parentElement; if (section) { section.style .setProperty( "display", "none", "important" ); } } ); } /* ===================================================== 5. REVIEW CARD DARK ===================================================== */ function darkReviewCard() { var elements = document.querySelectorAll( "p, div, span" ); elements.forEach( function (el) { var text = cleanText(el); if ( !text.includes( "شارك رأيك" ) || !text.includes( "ساعد غيرك" ) ) { return; } var card = el.closest( "section" ) || el.closest( "[class*='review']" ) || el.closest( "[class*='card']" ) || el.parentElement ?.parentElement; if (card) { card.classList.add( "wb-review-dark" ); } } ); } /* ===================================================== 6. CART POPUP BUTTONS RED ===================================================== */ function fixCartPopupButtons() { var targets = [ "إتمام الطلب", "عرض السلة" ]; document .querySelectorAll( "a, button" ) .forEach( function (el) { var text = cleanText(el); var match = targets.some( function (target) { return text.includes( target ); } ); if (!match) { return; } el.style.setProperty( "background", "#dc2626", "important" ); el.style.setProperty( "background-color", "#dc2626", "important" ); el.style.setProperty( "border-color", "#dc2626", "important" ); el.style.setProperty( "color", "#ffffff", "important" ); el.style.setProperty( "box-shadow", "0 8px 24px rgba(220,38,38,.20)", "important" ); el.querySelectorAll("*") .forEach( function (child) { child.style .setProperty( "color", "#ffffff", "important" ); } ); } ); } /* ===================================================== 7. ADD TO CART ALWAYS RED ===================================================== */ function makeAddToCartRed() { document .querySelectorAll( "button, a" ) .forEach( function (el) { var text = cleanText(el); if ( text !== "أضف إلى السلة" && text !== "إضافة إلى السلة" ) { return; } el.style.setProperty( "background", "#dc2626", "important" ); el.style.setProperty( "background-color", "#dc2626", "important" ); el.style.setProperty( "border-color", "#dc2626", "important" ); el.style.setProperty( "color", "#ffffff", "important" ); el.style.setProperty( "box-shadow", "0 8px 24px rgba(220,38,38,.28)", "important" ); el.querySelectorAll("*") .forEach( function (child) { child.style .setProperty( "color", "#ffffff", "important" ); } ); } ); } /* ===================================================== MASTER REFRESH مراقب واحد لجميع التعديلات ===================================================== */ var refreshPending = false; function refreshWenbel() { if (refreshPending) { return; } refreshPending = true; requestAnimationFrame( function () { refreshPending = false; installGlobalFooter(); keepFooterLast(); installProductTrust(); hideSuggestedProducts(); darkReviewCard(); fixCartPopupButtons(); makeAddToCartRed(); } ); } /* ===================================================== START ===================================================== */ function startWenbel() { refreshWenbel(); var observer = new MutationObserver( refreshWenbel ); observer.observe( document.body, { childList: true, subtree: true } ); window.addEventListener( "popstate", refreshWenbel ); window.addEventListener( "pageshow", refreshWenbel ); } if ( document.readyState === "loading" ) { document.addEventListener( "DOMContentLoaded", startWenbel ); } else { startWenbel(); } })(); /* ========================================================= WENBEL — CART SUCCESS POPUP DARK V3 ========================================================= */ (function () { "use strict"; function cleanText(el) { return (el.textContent || "") .replace(/\s+/g, " ") .trim(); } function isWhite(color) { if (!color) return false; var m = color.match( /rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/ ); if (!m) return false; return ( Number(m[1]) >= 235 && Number(m[2]) >= 235 && Number(m[3]) >= 235 ); } function darkenPopup() { var buttons = Array.from( document.querySelectorAll("a, button") ); var checkoutButton = buttons.find(function (el) { return cleanText(el).includes("إتمام الطلب"); }); var cartButton = buttons.find(function (el) { return cleanText(el).includes("عرض السلة"); }); /* النافذة غير مفتوحة */ if (!checkoutButton || !cartButton) return; /* * نبدأ من زر إتمام الطلب ونصعد للأعلى. * أول عنصر كبير بخلفية بيضاء هو حاوية النافذة. */ var current = checkoutButton; var popup = null; for (var i = 0; i < 10 && current; i++) { var style = window.getComputedStyle(current); var rect = current.getBoundingClientRect(); if ( isWhite(style.backgroundColor) && rect.width >= window.innerWidth * 0.75 && rect.height >= 180 ) { popup = current; break; } current = current.parentElement; } if (!popup) return; popup.style.setProperty( "background", "#08090d", "important" ); popup.style.setProperty( "background-color", "#08090d", "important" ); popup.style.setProperty( "color", "#f5f5f7", "important" ); /* * نحول الأسطح البيضاء الداخلية فقط. * الصور لا يتم تعديلها. */ popup.querySelectorAll("*").forEach(function (el) { if ( el.tagName === "IMG" || el.tagName === "SVG" || el.tagName === "PATH" ) { return; } var style = window.getComputedStyle(el); if (isWhite(style.backgroundColor)) { el.style.setProperty( "background-color", "#08090d", "important" ); } /* * النصوص الداكنة داخل النافذة */ var color = style.color; var m = color.match( /rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/ ); if ( m && Number(m[1]) < 100 && Number(m[2]) < 100 && Number(m[3]) < 100 ) { el.style.setProperty( "color", "#f5f5f7", "important" ); } }); /* * نعيد تثبيت الزرين بالأحمر بعد تحويل الخلفية */ [checkoutButton, cartButton].forEach(function (el) { el.style.setProperty( "background", "#dc2626", "important" ); el.style.setProperty( "background-color", "#dc2626", "important" ); el.style.setProperty( "border-color", "#dc2626", "important" ); el.style.setProperty( "color", "#ffffff", "important" ); el.querySelectorAll("*").forEach(function (child) { child.style.setProperty( "color", "#ffffff", "important" ); }); }); } darkenPopup(); new MutationObserver(function () { requestAnimationFrame(darkenPopup); }).observe( document.body, { childList: true, subtree: true } ); })(); /* ========================================================= WENBEL — CART TOTAL BAR DARK يستهدف شريط الإجمالي في صفحة السلة فقط ========================================================= */ (function () { "use strict"; function cleanText(el) { return (el.textContent || "") .replace(/\s+/g, " ") .trim(); } function isCartPage() { var path = window.location.pathname.toLowerCase(); return ( path.includes("/cart") || path.includes("shopping-cart") ); } function isWhite(color) { if (!color) return false; var match = color.match( /rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/ ); if (!match) return false; return ( Number(match[1]) >= 230 && Number(match[2]) >= 230 && Number(match[3]) >= 230 ); } function darkCartTotalBar() { if (!isCartPage()) return; var elements = Array.from( document.querySelectorAll( "div, section, aside, footer" ) ); /* * نبحث عن العنصر الذي يحتوي: * الإجمالي + عدد المنتجات + السعر */ var totalElement = elements.find(function (el) { var text = cleanText(el); return ( text.includes("الإجمالي") && /منتج/.test(text) && /[0-9٠-٩]/.test(text) && text.length < 150 ); }); if (!totalElement) return; /* * نصعد من عنصر الإجمالي حتى نصل * للحاوية البيضاء الفعلية. */ var current = totalElement; var totalBar = null; for (var i = 0; i < 7 && current; i++) { var style = window.getComputedStyle(current); var rect = current.getBoundingClientRect(); if ( isWhite(style.backgroundColor) && rect.width >= window.innerWidth * 0.80 && rect.height >= 55 ) { totalBar = current; break; } current = current.parentElement; } if (!totalBar) return; /* خلفية الشريط */ totalBar.style.setProperty( "background", "#16181f", "important" ); totalBar.style.setProperty( "background-color", "#16181f", "important" ); totalBar.style.setProperty( "border-color", "#2a303b", "important" ); totalBar.style.setProperty( "color", "#f5f5f7", "important" ); /* * تحويل النصوص الداكنة داخل الشريط إلى أبيض * بدون لمس زر إتمام الطلب أو الأيقونات. */ totalBar .querySelectorAll( "span, strong, b, p, h1, h2, h3, h4" ) .forEach(function (el) { el.style.setProperty( "color", "#f5f5f7", "important" ); }); /* * إزالة أي طبقة بيضاء داخل نفس الشريط. */ totalBar .querySelectorAll("div, section") .forEach(function (el) { var style = window.getComputedStyle(el); if (isWhite(style.backgroundColor)) { el.style.setProperty( "background-color", "#16181f", "important" ); } }); } darkCartTotalBar(); /* * سلة سلة تتحدث ديناميكيًا عند تغيير الكمية، * لذلك نحافظ على التصميم بعد أي تحديث. */ new MutationObserver(function () { requestAnimationFrame(darkCartTotalBar); }).observe( document.body, { childList: true, subtree: true } ); })(); /* ========================================================= WENBEL — CHECKOUT DARK UI V1 تصميم صفحة الدفع فقط ========================================================= */ (function () { "use strict"; const COLORS = { bg: "#08090d", card: "#16181f", field: "#101218", border: "#2a303b", text: "#f5f5f7", muted: "#8a8f9c", red: "#dc2626" }; function txt(el) { return (el.textContent || "") .replace(/\s+/g, " ") .trim(); } function rgb(color) { const m = String(color).match( /rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/ ); if (!m) return null; return { r: +m[1], g: +m[2], b: +m[3], a: m[4] === undefined ? 1 : +m[4] }; } function isLight(color) { const c = rgb(color); return c && c.a > 0 && c.r >= 225 && c.g >= 225 && c.b >= 225; } function isDarkText(color) { const c = rgb(color); return c && c.a > 0 && c.r < 125 && c.g < 125 && c.b < 125; } function isCheckout() { const bodyText = txt(document.body); /* * العلامات الظاهرة فعليًا في صفحة الدفع * حتى لا يعمل الكود في السلة أو المنتجات. */ return ( bodyText.includes("تأكيد الدفع") && bodyText.includes("الدفع") && ( bodyText.includes("بيانات البطاقة") || bodyText.includes("تفاصيل الطلب") ) ); } function protectElement(el) { return !!el.closest( "img, picture, svg, canvas, video, iframe" ); } function paintCheckout() { if (!document.body || !isCheckout()) return; document.documentElement.style.setProperty( "background-color", COLORS.bg, "important" ); document.body.style.setProperty( "background-color", COLORS.bg, "important" ); document.body.style.setProperty( "color", COLORS.text, "important" ); /* ----------------------------------------- تحويل الأسطح البيضاء الخارجية إلى داكنة ----------------------------------------- */ document.querySelectorAll( "main, section, article, aside, form, div" ).forEach(function (el) { if (protectElement(el)) return; const rect = el.getBoundingClientRect(); if (rect.width < 80 || rect.height < 30) return; const style = getComputedStyle(el); if (isLight(style.backgroundColor)) { const isLargeSurface = rect.width >= window.innerWidth * 0.85; el.style.setProperty( "background-color", isLargeSurface ? COLORS.bg : COLORS.card, "important" ); el.style.setProperty( "border-color", COLORS.border, "important" ); } }); /* ----------------------------------------- النصوص ----------------------------------------- */ document.querySelectorAll( "h1,h2,h3,h4,h5,h6,p,span,strong,b,label,small" ).forEach(function (el) { if (protectElement(el)) return; const style = getComputedStyle(el); /* * نحافظ على النص الأحمر مثل رابط الكوبون. */ const c = rgb(style.color); if ( c && c.r > 170 && c.g < 120 && c.b < 120 ) { return; } if (isDarkText(style.color)) { el.style.setProperty( "color", COLORS.text, "important" ); } }); /* ----------------------------------------- الحقول العادية فقط لا نتعامل مع iframe بوابة الدفع ----------------------------------------- */ document.querySelectorAll( "input:not([type='radio']):not([type='checkbox']), textarea, select" ).forEach(function (el) { /* * أي حقل موجود داخل iframe غير قابل للوصول * أصلًا، لذلك لا يتم المساس بحقول البوابة الآمنة. */ el.style.setProperty( "background-color", COLORS.field, "important" ); el.style.setProperty( "color", COLORS.text, "important" ); el.style.setProperty( "border-color", COLORS.border, "important" ); el.style.setProperty( "caret-color", COLORS.text, "important" ); }); /* ----------------------------------------- خيارات وسائل الدفع ----------------------------------------- */ const paymentNames = [ "مدى", "mada", "VISA", "PayPal", "STC" ]; document.querySelectorAll( "label, button, div" ).forEach(function (el) { const text = txt(el); if ( !paymentNames.some(function (name) { return text.includes(name); }) ) return; const rect = el.getBoundingClientRect(); /* * نستهدف بطاقة وسيلة الدفع نفسها * وليس الحاوية الكبيرة. */ if ( rect.width < 120 || rect.width > window.innerWidth * 0.65 || rect.height < 55 || rect.height > 160 ) return; el.style.setProperty( "background-color", COLORS.card, "important" ); el.style.setProperty( "border-color", COLORS.border, "important" ); el.style.setProperty( "color", COLORS.text, "important" ); }); /* ----------------------------------------- زر تأكيد الدفع ----------------------------------------- */ document.querySelectorAll( "button, a" ).forEach(function (el) { const text = txt(el); if (text !== "تأكيد الدفع") return; el.style.setProperty( "background", COLORS.red, "important" ); el.style.setProperty( "background-color", COLORS.red, "important" ); el.style.setProperty( "border-color", COLORS.red, "important" ); el.style.setProperty( "color", "#ffffff", "important" ); el.style.setProperty( "box-shadow", "0 8px 24px rgba(220,38,38,.24)", "important" ); el.querySelectorAll("*").forEach(function (child) { child.style.setProperty( "color", "#ffffff", "important" ); }); }); /* ----------------------------------------- الصور والشعارات ----------------------------------------- */ document.querySelectorAll( "img, picture, svg" ).forEach(function (el) { el.style.setProperty( "background-color", "transparent", "important" ); }); } let scheduled = false; function schedulePaint() { if (scheduled) return; scheduled = true; requestAnimationFrame(function () { scheduled = false; paintCheckout(); }); } if (document.readyState === "loading") { document.addEventListener( "DOMContentLoaded", schedulePaint ); } else { schedulePaint(); } /* * صفحة الدفع تتغير عند اختيار مدى / Visa وغيرها. * نعيد تطبيق الشكل بعد تحديث DOM فقط. */ new MutationObserver(schedulePaint).observe( document.documentElement, { childList: true, subtree: true } ); })();