/* ========================================================= OTOM Professional Page System الرئيسية / الحجز / المنتجات + قائمة ثابتة بدون MutationObserver وبدون إخفاء خطير ========================================================= */ (function () { "use strict"; var HOME_URL = "https://otom.com.sa/"; var LANDING_IMG = "https://cdn.salla.sa/zByPK/q7SRHZa1tLjsh4h1TkXWZPjw9pL7D78EwYFEecic.png"; var CARE_HEADER_IMG = "https://cdn.salla.sa/zByPK/HhICfKsi7GVXFasiA9YX6ird86tpQzQpK6J7wuOC.png"; var CARE_CATEGORY_URL = "https://otom.com.sa/%D9%85%D9%86%D8%AA%D8%AC%D8%A7%D8%AA-%D8%A7%D9%84%D8%B9%D9%86%D8%A7%D9%8A%D8%A9-%D8%A8%D8%A7%D9%84%D8%B3%D9%8A%D8%A7%D8%B1%D8%A9/c950276138"; var BOOKING_URL = "https://otom.com.sa/#booking"; function isHomePage() { var path = (window.location.pathname || "/").replace(/\/+$/, ""); return document.body.classList.contains("index") || path === "" || path === "/"; } function isProductDetailPage() { var path = window.location.pathname || ""; return /\/p\d+/i.test(path) || path.indexOf("/p") > -1 || !!document.querySelector("salla-product-options, .s-product-single, .product-single, .product-entry"); } function isCareCategoryPage() { var href = decodeURIComponent(window.location.href || ""); return href.indexOf("c950276138") > -1 || href.indexOf("منتجات-العناية-بالسيارة") > -1 || href.indexOf("منتجات العناية بالسيارة") > -1; } function clearOldLanding() { var selectors = [ ".otom-main-landing", ".otom-landing-screen", ".otom-safe-landing", ".otom-final-landing", ".otom-new-landing", ".otom-landing-layer", ".otom-controlled-landing", "#otom-controlled-landing", "#otom-home-hub" ]; selectors.forEach(function (selector) { document.querySelectorAll(selector).forEach(function (el) { el.remove(); }); }); } function addGlobalNav(active) { var old = document.querySelector(".otom-global-nav"); if (old) old.remove(); var nav = document.createElement("nav"); nav.className = "otom-global-nav"; nav.setAttribute("aria-label", "تنقل أوتوم الرئيسي"); nav.innerHTML = 'الرئيسية' + 'الحجز' + 'المنتجات'; document.body.appendChild(nav); nav.querySelectorAll("a").forEach(function (link) { if (link.getAttribute("data-otom-nav") === active) { link.classList.add("is-active"); } }); var homeLink = nav.querySelector('[data-otom-nav="home"]'); var bookingLink = nav.querySelector('[data-otom-nav="booking"]'); if (homeLink) { homeLink.addEventListener("click", function (e) { if (isHomePage()) { e.preventDefault(); history.pushState({ otomView: "home" }, "", "/"); showHomeHub(); } }); } if (bookingLink) { bookingLink.addEventListener("click", function (e) { if (isHomePage()) { e.preventDefault(); openBookingView(true); } }); } } function createHomeHub() { if (!isHomePage() || isProductDetailPage() || isCareCategoryPage()) return; clearOldLanding(); var hub = document.createElement("section"); hub.id = "otom-home-hub"; hub.className = "otom-home-hub"; hub.setAttribute("aria-label", "صفحة أوتوم الرئيسية"); hub.innerHTML = '
' + 'أوتوم - حجز غسيل السيارات ومنتجات العناية' + '' + '' + '
'; document.body.insertBefore(hub, document.body.firstChild); var bookingBtn = hub.querySelector(".otom-home-booking-hit"); var productsBtn = hub.querySelector(".otom-home-products-hit"); if (bookingBtn) { bookingBtn.addEventListener("click", function (e) { e.preventDefault(); e.stopPropagation(); openBookingView(true); }, true); } if (productsBtn) { productsBtn.addEventListener("click", function (e) { e.preventDefault(); e.stopPropagation(); window.location.href = CARE_CATEGORY_URL; }, true); } } function showHomeHub() { if (!isHomePage() || isProductDetailPage() || isCareCategoryPage()) return; if (!document.getElementById("otom-home-hub")) { createHomeHub(); } document.body.classList.add("otom-home-landing-active"); document.body.classList.remove("otom-booking-view-active"); addGlobalNav("home"); var hub = document.getElementById("otom-home-hub"); if (hub) { hub.style.setProperty("display", "flex", "important"); hub.scrollTop = 0; } window.scrollTo(0, 0); } function hideHomeHub() { document.body.classList.remove("otom-home-landing-active"); document.body.classList.add("otom-booking-view-active"); var hub = document.getElementById("otom-home-hub"); if (hub) hub.style.setProperty("display", "none", "important"); addGlobalNav("booking"); } function getRiyadhNow() { var parts = new Intl.DateTimeFormat("en-US", { timeZone: "Asia/Riyadh", year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: false }).formatToParts(new Date()); var data = {}; parts.forEach(function (part) { data[part.type] = part.value; }); return new Date( Number(data.year), Number(data.month) - 1, Number(data.day), Number(data.hour), Number(data.minute), Number(data.second) ); } function updateOtomSlotsCounter() { var slotsEl = document.getElementById("otom-available-slots"); var titleEl = document.getElementById("otom-slots-countdown-title"); var hoursEl = document.getElementById("otom-slots-hours"); var minutesEl = document.getElementById("otom-slots-minutes"); var secondsEl = document.getElementById("otom-slots-seconds"); if (!slotsEl || !titleEl || !hoursEl || !minutesEl || !secondsEl) return; var now = getRiyadhNow(); var hour = now.getHours(); var minute = now.getMinutes(); var currentMinutes = hour * 60 + minute; if (hour < 2) currentMinutes += 24 * 60; var openMinutes = 14 * 60; var closeMinutes = 26 * 60; var blockMinutes = 90; var maxSlots = 24; var decreasePerBlock = 3; var isServiceOpen = currentMinutes >= openMinutes && currentMinutes < closeMinutes; var availableSlots = maxSlots; var target = new Date(now); var countdownTitle = ""; if (isServiceOpen) { var elapsedMinutes = currentMinutes - openMinutes; var completedBlocks = Math.floor(elapsedMinutes / blockMinutes); availableSlots = Math.max(0, maxSlots - completedBlocks * decreasePerBlock); target = new Date(now); target.setHours(2, 0, 0, 0); if (hour >= 14) target.setDate(target.getDate() + 1); countdownTitle = "تنتهي خدماتنا خلال"; } else { availableSlots = maxSlots; target = new Date(now); if (hour >= 2 && hour < 14) { target.setHours(14, 0, 0, 0); } else { target.setDate(target.getDate() + 1); target.setHours(14, 0, 0, 0); } countdownTitle = "نفتتح خدماتنا خلال"; } var diff = Math.max(0, target - now); var totalSeconds = Math.floor(diff / 1000); slotsEl.textContent = availableSlots; titleEl.textContent = countdownTitle; hoursEl.textContent = String(Math.floor(totalSeconds / 3600)).padStart(2, "0"); minutesEl.textContent = String(Math.floor((totalSeconds % 3600) / 60)).padStart(2, "0"); secondsEl.textContent = String(totalSeconds % 60).padStart(2, "0"); } function insertBookingIntro() { if (!isHomePage()) return; if (document.querySelector(".otom-quick")) return; var firstProduct = document.querySelector(".s-product-card-entry"); if (!firstProduct) return; var back = document.createElement("a"); back.href = "/"; back.className = "otom-back-to-hub"; back.textContent = "العودة للصفحة الرئيسية"; var box = document.createElement("div"); box.className = "otom-quick"; box.id = "otom-booking-services"; box.innerHTML = '
' + '
اختر خدمة أوتوم المناسبة لسيارتك
' + '
غسيل سيارات متنقل في شرق الرياض، نصل إلى موقعك في المنزل أو العمل.
' + '
' + '
المواعيد المتاحة اليوم
' + '
24مواعيد متاحة
' + '
جاري حساب الوقت
' + '
' + '
00ساعة
' + ':' + '
00دقيقة
' + ':' + '
00ثانية
' + '
' + '
' + '
'; firstProduct.parentNode.insertBefore(back, firstProduct); firstProduct.parentNode.insertBefore(box, firstProduct); back.addEventListener("click", function (e) { if (isHomePage()) { e.preventDefault(); history.pushState({ otomView: "home" }, "", "/"); showHomeHub(); } }); updateOtomSlotsCounter(); } function updateButtons() { if (!isHomePage()) return; document.querySelectorAll(".s-product-card-entry button, .s-product-card-entry .s-button-element").forEach(function (btn) { var text = btn.innerText || ""; if ( text.includes("إضافة") || text.includes("السلة") || text.includes("Add") || text.includes("شراء") || text.includes("اشتري") || text.includes("العرض") ) { btn.innerText = "احجز الآن"; } }); } function removeWishlist() { document.querySelectorAll( '.s-product-card-entry [class*="wishlist"], .s-product-card-entry [class*="favorite"], .s-product-card-entry [class*="heart"], .s-product-card-entry [class*="rating"]' ).forEach(function (el) { el.remove(); }); } function addWhatsApp() { if (document.querySelector(".otom-whatsapp")) return; var w = document.createElement("a"); w.className = "otom-whatsapp"; w.href = "https://wa.me/966542905335?text=السلام عليكم، أحتاج مساعدة في حجز غسيل سيارة"; w.target = "_blank"; w.rel = "noopener"; w.innerText = "نساعدك بالحجز"; document.body.appendChild(w); } function findBookingTarget() { return document.querySelector("#otom-booking-services") || document.querySelector(".otom-quick") || document.querySelector(".s-product-card-entry") || document.querySelector("salla-products-list") || document.querySelector(".products-list"); } function openBookingView(pushHistory) { if (!isHomePage()) { window.location.href = BOOKING_URL; return; } hideHomeHub(); insertBookingIntro(); updateButtons(); removeWishlist(); if (pushHistory && window.location.hash !== "#booking") { history.pushState({ otomView: "booking" }, "", "#booking"); } else if (window.location.hash === "#booking") { history.replaceState({ otomView: "booking" }, "", "#booking"); } setTimeout(function () { var target = findBookingTarget(); if (target) { target.scrollIntoView({ behavior: "smooth", block: "start" }); } }, 100); } function handleHomeRoute() { if (!isHomePage() || isProductDetailPage() || isCareCategoryPage()) return; insertBookingIntro(); updateButtons(); removeWishlist(); if (window.location.hash === "#booking") { openBookingView(false); } else { showHomeHub(); } } function hideCareSortOnly() { if (!isCareCategoryPage()) return; document.querySelectorAll("select").forEach(function (el) { var text = (el.innerText || el.value || "").trim(); if ( text.includes("مقترحاتنا") || text.includes("السعر") || text.includes("الأكثر") || text.includes("ترتيب") ) { el.style.setProperty("display", "none", "important"); } }); document.querySelectorAll("h1, h2, h3, .s-slider-block__title, .s-block__title, .s-section-title, label, span").forEach(function (el) { if (el.closest(".otom-care-catalog-hero") || el.closest(".otom-care-products-heading")) return; var text = (el.innerText || "").trim(); if (text === "مقترحاتنا" || text.includes("مقترحاتنا") || text === "السعر") { el.classList.add("otom-hide-recommendation-title"); } if (text.includes("منتجات العناية بالسيارة") && !el.closest(".breadcrumb")) { el.classList.add("otom-hide-recommendation-title"); } }); } function countCareProducts() { return document.querySelectorAll( "body.otom-care-category-page .s-product-card-entry, body.otom-care-category-page salla-product-card, body.otom-care-category-page .product-entry" ).length; } function findCareProductsAnchor() { return document.querySelector("salla-products-list") || document.querySelector(".s-products-list") || document.querySelector(".products-list") || document.querySelector(".s-product-card-entry") || document.querySelector("salla-product-card") || document.querySelector(".product-entry"); } function enableSallaProductsAutoload() { document.querySelectorAll("salla-products-list").forEach(function (list) { list.setAttribute("autoload", "true"); list.autoload = true; /* لا نفرض sort-by حتى لا يتحول لمقترحات أو أكثر مبيعاً */ if (list.hasAttribute("sort-by")) { list.removeAttribute("sort-by"); } }); } function revealAllCareProductCards() { document.querySelectorAll( "body.otom-care-category-page .s-product-card-entry, body.otom-care-category-page salla-product-card, body.otom-care-category-page .product-entry" ).forEach(function (card) { card.style.setProperty("display", "flex", "important"); card.style.setProperty("visibility", "visible", "important"); card.style.setProperty("opacity", "1", "important"); }); } function clickLoadMoreIfExists() { var candidates = Array.from(document.querySelectorAll("button, a, .s-button-element")); var btn = candidates.find(function (el) { var text = (el.innerText || "").trim(); if (!text) return false; return text.includes("عرض المزيد") || text.includes("تحميل المزيد") || text.includes("المزيد") || text.includes("Load more") || text.includes("More"); }); if (btn && !btn.disabled && btn.offsetParent !== null) { btn.click(); return true; } return false; } function setupCareCategory() { document.body.classList.add("otom-care-category-page"); addGlobalNav("products"); document.querySelectorAll( ".otom-care-header, .otom-care-catalog-hero, .otom-care-products-heading, .otom-care-final-booking" ).forEach(function (el) { el.remove(); }); enableSallaProductsAutoload(); hideCareSortOnly(); var container = document.querySelector("main") || document.querySelector(".main-content") || document.querySelector(".page-wrapper") || document.body; var anchor = findCareProductsAnchor(); var hero = document.createElement("section"); hero.className = "otom-care-catalog-hero"; hero.innerHTML = 'منتجات العناية للسيارة' + '

جميع منتجات العناية بالسيارة

' + '

إكسسوارات، تنظيم، أدوات طوارئ، ماطور هواء ومنتجات عملية للسيارة.

' + '
' + 'إكسسوارات' + 'ماطور هواء' + 'تنظيم' + 'طوارئ' + '
'; var heading = document.createElement("section"); heading.className = "otom-care-products-heading"; heading.innerHTML = '

كل المنتجات

' + 'جاري التحميل'; var parentForInsert = container; var insertBeforeNode = anchor; if (anchor) { var block = anchor.closest("section") || anchor.parentNode; if (block && block.parentNode && block !== document.body) { parentForInsert = block.parentNode; insertBeforeNode = block; } else if (anchor.parentNode) { parentForInsert = anchor.parentNode; insertBeforeNode = anchor; } } if (parentForInsert && insertBeforeNode) { parentForInsert.insertBefore(hero, insertBeforeNode); parentForInsert.insertBefore(heading, insertBeforeNode); } else { container.insertBefore(hero, container.firstChild); hero.insertAdjacentElement("afterend", heading); } var footer = document.createElement("a"); footer.className = "otom-care-final-booking"; footer.href = BOOKING_URL; footer.textContent = "حجز خدمة غسيل السيارة"; container.appendChild(footer); function refreshCareProducts() { enableSallaProductsAutoload(); hideCareSortOnly(); revealAllCareProductCards(); document.querySelectorAll( "body.otom-care-category-page .s-product-card-entry button, body.otom-care-category-page .s-product-card-entry .s-button-element" ).forEach(function (btn) { var text = btn.innerText || ""; if ( text.includes("احجز") || text.includes("إضافة") || text.includes("السلة") || text.includes("Add") || text.includes("شراء") ) { btn.innerText = "أضف المنتج"; } }); var countEl = document.getElementById("otom-care-products-count"); if (countEl) { var count = countCareProducts(); countEl.textContent = count > 0 ? count + " منتجات ظاهرة" : "لم يتم تحميل المنتجات"; } } refreshCareProducts(); /* تمريرات محدودة لتفعيل autoload إن كانت سلة تحمل المنتجات عند الوصول للأسفل. بدون MutationObserver وبدون حلقات مفتوحة. */ [600, 1400, 2500, 3800, 5200, 7000].forEach(function (delay) { setTimeout(function () { enableSallaProductsAutoload(); clickLoadMoreIfExists(); refreshCareProducts(); }, delay); }); } function setupProductDetail() { document.body.classList.add("otom-product-detail-page"); addGlobalNav(""); document.querySelectorAll( "#otom-home-hub, .otom-main-landing, .otom-landing-screen, .otom-safe-landing, .otom-final-landing, .otom-new-landing, .otom-landing-layer, .otom-quick, .otom-slots-counter" ).forEach(function (el) { el.remove(); }); } function init() { if (isProductDetailPage()) { setupProductDetail(); return; } if (isCareCategoryPage()) { setupCareCategory(); return; } if (isHomePage()) { document.body.classList.add("otom-home-page"); createHomeHub(); insertBookingIntro(); updateButtons(); removeWishlist(); addWhatsApp(); handleHomeRoute(); setInterval(updateOtomSlotsCounter, 1000); return; } addGlobalNav(""); } document.addEventListener("DOMContentLoaded", init); window.addEventListener("popstate", function () { setTimeout(handleHomeRoute, 30); }); window.addEventListener("hashchange", function () { setTimeout(handleHomeRoute, 30); }); window.addEventListener("pageshow", function () { setTimeout(function () { if (isHomePage() && !isProductDetailPage() && !isCareCategoryPage()) { handleHomeRoute(); } }, 60); }); })(); /* ========================================================= OTOM Premium Navigation Integrated ========================================================= */ /* ========================================================= OTOM Premium Global Navigation Add-on يحدّث النصوص ويضمن ثبات القائمة في كل الصفحات أضفه بعد الأكواد الحالية ========================================================= */ (function () { "use strict"; function currentView() { var href = decodeURIComponent(window.location.href || ""); var path = (window.location.pathname || "").replace(/\/+$/, ""); var isCare = href.indexOf("c950276138") > -1 || href.indexOf("منتجات-العناية-بالسيارة") > -1 || href.indexOf("منتجات العناية بالسيارة") > -1; var isBooking = window.location.hash === "#booking"; var isHome = document.body.classList.contains("index") || path === "" || path === "/" || path === "https://otom.com.sa"; if (isCare) return "products"; if (isBooking) return "booking"; if (isHome) return "home"; return ""; } function styleNav() { var nav = document.querySelector(".otom-global-nav"); if (!nav) return; nav.querySelectorAll("a").forEach(function (a) { var kind = a.getAttribute("data-otom-nav") || ""; if (kind === "home") { a.innerHTML = 'الرئيسية'; } else if (kind === "booking") { a.innerHTML = 'خدمات الحجز'; } else if (kind === "products") { a.innerHTML = 'منتجاتنا'; } }); var active = currentView(); nav.querySelectorAll("a").forEach(function (a) { a.classList.remove("is-active"); if ((a.getAttribute("data-otom-nav") || "") === active) { a.classList.add("is-active"); } }); } function goHome(e) { if (e) e.preventDefault(); window.location.href = "https://otom.com.sa/"; } function goBooking(e) { if (e) e.preventDefault(); var path = (window.location.pathname || "").replace(/\/+$/, ""); var isHome = document.body.classList.contains("index") || path === "" || path === "/"; if (isHome) { if (window.location.hash !== "#booking") { history.pushState({ otomView: "booking" }, "", "#booking"); } window.dispatchEvent(new HashChangeEvent("hashchange")); setTimeout(function () { var target = document.querySelector("#otom-booking-services") || document.querySelector(".otom-quick") || document.querySelector(".s-product-card-entry"); if (target) { target.scrollIntoView({behavior: "smooth", block: "start"}); } }, 120); } else { window.location.href = "https://otom.com.sa/#booking"; } } function goProducts(e) { if (e) e.preventDefault(); window.location.href = "https://otom.com.sa/%D9%85%D9%86%D8%AA%D8%AC%D8%A7%D8%AA-%D8%A7%D9%84%D8%B9%D9%86%D8%A7%D9%8A%D8%A9-%D8%A8%D8%A7%D9%84%D8%B3%D9%8A%D8%A7%D8%B1%D8%A9/c950276138"; } function bindNav() { var nav = document.querySelector(".otom-global-nav"); if (!nav || nav.getAttribute("data-otom-premium-bound") === "1") return; nav.setAttribute("data-otom-premium-bound", "1"); var home = nav.querySelector('[data-otom-nav="home"]'); var booking = nav.querySelector('[data-otom-nav="booking"]'); var products = nav.querySelector('[data-otom-nav="products"]'); if (home) home.addEventListener("click", goHome); if (booking) booking.addEventListener("click", goBooking); if (products) products.addEventListener("click", goProducts); } function run() { styleNav(); bindNav(); } document.addEventListener("DOMContentLoaded", function () { run(); setTimeout(run, 300); setTimeout(run, 1200); }); window.addEventListener("hashchange", function () { setTimeout(run, 80); }); window.addEventListener("pageshow", function () { setTimeout(run, 80); }); })(); /* ========================================================= OTOM Products Same Booking Card Style JS توحيد نص زر المنتجات مع عدم لمس خدمات الحجز ========================================================= */ (function(){ "use strict"; function isCareCategoryPage(){ var href = decodeURIComponent(window.location.href || ""); return href.indexOf("c950276138") > -1 || href.indexOf("منتجات-العناية-بالسيارة") > -1 || href.indexOf("منتجات العناية بالسيارة") > -1; } function fixCareProductButtons(){ if(!isCareCategoryPage()) return; document.querySelectorAll(".s-product-card-entry button, .s-product-card-entry .s-button-element").forEach(function(btn){ var text = btn.innerText || ""; if( text.includes("احجز") || text.includes("إضافة") || text.includes("السلة") || text.includes("Add") || text.includes("شراء") ){ btn.innerText = "أضف المنتج"; } }); } document.addEventListener("DOMContentLoaded", function(){ fixCareProductButtons(); setTimeout(fixCareProductButtons, 600); setTimeout(fixCareProductButtons, 1500); }); window.addEventListener("pageshow", function(){ setTimeout(fixCareProductButtons, 100); }); })(); /* ========================================================= OTOM Product Description Visibility إظهار وصف المنتج وتوحيد زر المنتج في صفحة العناية فقط ========================================================= */ (function(){ "use strict"; function isCareCategoryPage(){ var href = decodeURIComponent(window.location.href || ""); return href.indexOf("c950276138") > -1 || href.indexOf("منتجات-العناية-بالسيارة") > -1 || href.indexOf("منتجات العناية بالسيارة") > -1; } function refineProductCards(){ if(!isCareCategoryPage()) return; document.querySelectorAll(".s-product-card-entry").forEach(function(card){ /* لا تخفي الوصف إن كان موجوداً */ card.querySelectorAll(".s-product-card-content-description, .s-product-card-content-subtitle, [class*='description'], [class*='subtitle']").forEach(function(el){ el.style.setProperty("display", "block", "important"); el.style.setProperty("visibility", "visible", "important"); el.style.setProperty("opacity", "1", "important"); el.style.setProperty("max-height", "none", "important"); el.style.setProperty("overflow", "visible", "important"); el.style.setProperty("white-space", "normal", "important"); }); /* توحيد نص الزر */ card.querySelectorAll("button, .s-button-element").forEach(function(btn){ var text = btn.innerText || ""; if( text.includes("احجز") || text.includes("إضافة") || text.includes("السلة") || text.includes("Add") || text.includes("شراء") ){ btn.innerText = "أضف المنتج"; } }); }); } document.addEventListener("DOMContentLoaded", function(){ refineProductCards(); setTimeout(refineProductCards, 500); setTimeout(refineProductCards, 1400); }); window.addEventListener("pageshow", function(){ setTimeout(refineProductCards, 120); }); })(); /* ========================================================= OTOM Booking Services Tables Restore JS يعيد جداول خدمات الغسيل فقط داخل صفحة الحجز ========================================================= */ (function(){ "use strict"; function isHomePage(){ var path = (window.location.pathname || "/").replace(/\/+$/, ""); return document.body.classList.contains("index") || path === "" || path === "/"; } function isCareCategoryPage(){ var href = decodeURIComponent(window.location.href || ""); return href.indexOf("c950276138") > -1 || href.indexOf("منتجات-العناية-بالسيارة") > -1 || href.indexOf("منتجات العناية بالسيارة") > -1; } function isProductDetailPage(){ var path = window.location.pathname || ""; return /\/p\d+/i.test(path) || path.indexOf("/p") > -1 || !!document.querySelector("salla-product-options, .s-product-single, .product-single, .product-entry"); } function buildFeatureTable(features){ var box = document.createElement("div"); box.className = "otom-features"; box.innerHTML = features.map(function(item){ return '
' + '' + item[0] + '' + '' + item[1] + '' + '
'; }).join(""); return box; } function addFixedServicePrice(card, price){ if(card.querySelector(".otom-fixed-price-box")) return; var fixedPrice = document.createElement("div"); fixedPrice.className = "otom-fixed-price-box"; fixedPrice.innerHTML = '' + price + 'ريال'; var btn = card.querySelector("button, .s-button-element"); if(btn && btn.parentNode){ btn.parentNode.insertBefore(fixedPrice, btn); } else { var content = card.querySelector(".s-product-card-content") || card; content.appendChild(fixedPrice); } } function restoreBookingServiceTables(){ if(!isHomePage() || isCareCategoryPage() || isProductDetailPage()) return; document.querySelectorAll(".s-product-card-entry").forEach(function(card){ var text = card.innerText || ""; var isFull = text.includes("غسيل شامل") || text.includes("شامل سريع") || text.includes("داخلي وخارجي") || text.includes("داخلي"); var isExternal = !isFull && ( text.includes("غسيل خارجي سريع") || text.includes("غسيل خارجي") || text.includes("خارجي سريع") ); if(!isFull && !isExternal) return; card.classList.add("otom-booking-service-card"); if(!card.querySelector(".otom-features")){ var features = isFull ? [ ["المدة", "45 دقيقة"], ["الخدمة", "داخلي وخارجي"], ["يشمل", "تنظيف داخلي + غسيل خارجي"] ] : [ ["المدة", "30 دقيقة"], ["الخدمة", "غسيل خارجي سريع"], ["يشمل", "غسيل خارجي + زجاج + واكس"] ]; var table = buildFeatureTable(features); var price = card.querySelector(".s-product-card-price, .s-price"); if(price && price.parentNode){ price.parentNode.insertBefore(table, price); } else { var title = card.querySelector(".s-product-card-content-title, h3"); if(title && title.parentNode){ title.parentNode.insertBefore(table, title.nextSibling); } else { (card.querySelector(".s-product-card-content") || card).appendChild(table); } } } addFixedServicePrice(card, isFull ? "49.75" : "34.75"); card.querySelectorAll("button, .s-button-element").forEach(function(btn){ var txt = btn.innerText || ""; if( txt.includes("إضافة") || txt.includes("السلة") || txt.includes("Add") || txt.includes("شراء") || txt.includes("اشتري") || txt.includes("العرض") || txt.includes("أضف المنتج") ){ btn.innerText = "احجز الآن"; } }); }); } document.addEventListener("DOMContentLoaded", function(){ restoreBookingServiceTables(); setTimeout(restoreBookingServiceTables, 600); setTimeout(restoreBookingServiceTables, 1500); }); window.addEventListener("hashchange", function(){ setTimeout(restoreBookingServiceTables, 120); }); window.addEventListener("pageshow", function(){ setTimeout(restoreBookingServiceTables, 120); }); })(); /* ========================================================= OTOM Care Products Image Fit Only JS يزيل قص الصور داخل صفحة منتجات العناية فقط ========================================================= */ (function(){ "use strict"; function isCareCategoryPage(){ var href = decodeURIComponent(window.location.href || ""); return href.indexOf("c950276138") > -1 || href.indexOf("منتجات-العناية-بالسيارة") > -1 || href.indexOf("منتجات العناية بالسيارة") > -1; } function fitCareProductImages(){ if(!isCareCategoryPage()) return; document.querySelectorAll(".s-product-card-entry .s-product-card-image").forEach(function(box){ box.style.setProperty("overflow", "hidden", "important"); box.style.setProperty("display", "flex", "important"); box.style.setProperty("align-items", "center", "important"); box.style.setProperty("justify-content", "center", "important"); }); document.querySelectorAll(".s-product-card-entry .s-product-card-image img, .s-product-card-entry picture img").forEach(function(img){ img.style.setProperty("width", "auto", "important"); img.style.setProperty("height", "auto", "important"); img.style.setProperty("max-width", "100%", "important"); img.style.setProperty("max-height", "100%", "important"); img.style.setProperty("object-fit", "contain", "important"); img.style.setProperty("object-position", "center center", "important"); img.style.setProperty("padding", "0", "important"); img.style.setProperty("margin", "auto", "important"); }); } document.addEventListener("DOMContentLoaded", function(){ fitCareProductImages(); setTimeout(fitCareProductImages, 500); setTimeout(fitCareProductImages, 1400); }); window.addEventListener("pageshow", function(){ setTimeout(fitCareProductImages, 120); }); })(); /* ========================================================= OTOM Manual Care Products Catalog JS - Final ========================================================= */ (function(){ "use strict"; var PRODUCTS = [{"title": "عدة إصلاح إطارات Tubeless", "subtitle": "حل طوارئ عملي لثقوب الإطارات البسيطة", "price": "59", "url": "https://otom.com.sa/bwGwvRw", "img": "https://cdn.salla.sa/zByPK/8ae08641-3e45-4632-8a9e-1d6fef7540b9-1000x1000-btrsQWMopIqgcyUba9MKedKTzarlVdwsh7vMekwV.jpg", "tag": "طوارئ", "desc": "عدة مخصصة للإطارات Tubeless تساعدك في الإصلاح المؤقت عند حدوث ثقب بسيط حتى تصل لمركز الصيانة."}, {"title": "ماطور هواء رقمي للسيارة 150PSI", "subtitle": "افحص وانفخ الإطار بسهولة وقت الحاجة", "price": "149", "url": "https://otom.com.sa/ABRBNEq", "img": "https://cdn.salla.sa/zByPK/521014a7-a67d-4948-a535-467cb9cab72c-1000x1000-8UsKs3tBT4yIxzA0BbNJyIXMPC5GbdOGqUSQl7aC.jpg", "tag": "ماطور هواء", "desc": "منفاخ رقمي يعمل من منفذ السيارة 12V مع شاشة وضبط ضغط، مناسب للطوارئ والرحلات والاستخدام اليومي."}, {"title": "محول كهرباء للسيارة Baseus 150W", "subtitle": "حوّل منفذ السيارة إلى مصدر طاقة", "price": "149", "url": "https://otom.com.sa/RvevXlv", "img": "https://cdn.salla.sa/zByPK/5817046c-e820-47f6-b299-48e0ca0563f3-1000x1000-IR44SpgcwAYCLWWAxvq3cOy6l94wdjICJRGejB2F.jpg", "tag": "طاقة", "desc": "محول عملي لشحن الأجهزة الصغيرة أثناء التنقل، مناسب للجوال والباور بانك وبعض الأجهزة ضمن القدرة المسموحة."}, {"title": "منشفة مايكروفايبر للسيارة 600GSM", "subtitle": "تنظيف وتجفيف ناعم بدون وبر واضح", "price": "19", "url": "https://otom.com.sa/wANAYxe", "img": "https://cdn.salla.sa/zByPK/d0dfc5bb-5ca6-41d3-8b8b-b99f4ce922b9-1000x998.10606060606-lF8X4aFjZQdo0QGShYBVzdm1vIZD7YUvKClnkDZ3.png", "tag": "تنظيف", "desc": "منشفة ناعمة للعناية بالزجاج والطبلون والهيكل الخارجي، مناسبة للتجفيف والتنظيف بعد الغسيل."}, {"title": "حامل جوال مغناطيسي للطبلون", "subtitle": "ثبّت جوالك بوضوح أثناء القيادة", "price": "49", "url": "https://otom.com.sa/ngNgRmw", "img": "https://cdn.salla.sa/zByPK/a363675a-940b-4cc7-8c19-0c5a36746c59-949.34333958724x1000-silc7vPiyebWilfjHM5JIWcJ2tFmUPfQYmN2YKAx.png", "tag": "إكسسوارات", "desc": "حامل مغناطيسي عملي للطبلون يساعدك على استخدام الخرائط والمكالمات بثبات وبشكل آمن."}, {"title": "منظم فراغات السيارة مع حامل كوب", "subtitle": "رتّب الجوال والمفاتيح والبطاقات", "price": "49", "url": "https://otom.com.sa/wANAdeV", "img": "https://cdn.salla.sa/zByPK/c585f0e7-a5f5-418c-bea4-d3f5b81c81ee-1000x987.70491803279-rCeTG2uydWjDgqpNz7yYuW3raOTwmAVe8iuNYZsg.jpg", "tag": "تنظيم", "desc": "منظم يوضع بين المقعد والكونسول لتقليل الفوضى ومنع سقوط الأغراض الصغيرة داخل السيارة."}, {"title": "سلة مهملات سيارة", "subtitle": "حافظ على نظافة السيارة يومياً", "price": "29", "url": "https://otom.com.sa/oZNZOlr", "img": "https://cdn.salla.sa/zByPK/c07610ca-983b-465a-acef-4c78b4177b98-1000x1000-il2dzXTEx06Zy9ES0qwebCq6hoSUykhx4llvmPF7.jpg", "tag": "تنظيم", "desc": "سلة قابلة للطي تساعد على ترتيب السيارة والتخلص من المخلفات الخفيفة داخل السيارة بشكل أنيق."}]; function isCareCategoryPage(){ var href = decodeURIComponent(window.location.href || ""); return href.indexOf("c950276138") > -1 || href.indexOf("منتجات-العناية-بالسيارة") > -1 || href.indexOf("منتجات العناية بالسيارة") > -1; } function esc(str){ return String(str || "").replace(/&/g, "&").replace(//g, ">").replace(/"/g, """); } function cardHtml(product){ return '' + '' + '
' + '' + esc(product.title) + '' + '
' + '
' + '' + esc(product.tag) + '' + '

' + esc(product.title) + '

' + '

' + esc(product.subtitle) + '

' + '

' + esc(product.desc) + '

' + '' + '
' + '
'; } function buildManualCareCatalog(){ if(!isCareCategoryPage()) return; document.body.classList.add("otom-care-category-page"); if(document.querySelector(".otom-manual-care-catalog")){ document.body.classList.add("otom-manual-products-ready"); return; } var container = document.querySelector("main") || document.querySelector(".main-content") || document.querySelector(".page-wrapper") || document.body; var catalog = document.createElement("section"); catalog.className = "otom-manual-care-catalog"; catalog.innerHTML = '
' + 'منتجات العناية للسيارة' + '

جميع منتجات العناية بالسيارة

' + '

إكسسوارات وتنظيم وأدوات طوارئ ومنتجات عملية مختارة للسيارة.

' + '
' + '
' + '

كل المنتجات

' + '' + PRODUCTS.length + ' منتجات' + '
' + '
' + PRODUCTS.map(cardHtml).join("") + '
'; var anchor = document.querySelector(".otom-care-catalog-hero") || document.querySelector(".otom-care-products-heading") || document.querySelector("salla-products-list") || document.querySelector(".s-product-card-entry") || document.querySelector(".products-list"); if(anchor && anchor.parentNode){ anchor.parentNode.insertBefore(catalog, anchor); } else { container.appendChild(catalog); } document.body.classList.add("otom-manual-products-ready"); } document.addEventListener("DOMContentLoaded", function(){ buildManualCareCatalog(); setTimeout(buildManualCareCatalog, 600); setTimeout(buildManualCareCatalog, 1500); }); window.addEventListener("pageshow", function(){ setTimeout(buildManualCareCatalog, 120); }); })();