/* ========================================================= CHĂM SÓC — TESTIMONIALS AUTO SLIDE ========================================================= */ (function () { const DELAY = 6000; function init() { const host = document.querySelector( '.s-block--bundle-trust-testimonials [component-name="trust-testimonials"]' ); if (!host) { setTimeout(init, 500); return; } const root = host.shadowRoot || host; const slider = root.querySelector('salla-slider'); if (!slider) { setTimeout(init, 500); return; } const sliderRoot = slider.shadowRoot || slider; function nextSlide() { /* Try the native Swiper instance first */ const swiperElement = sliderRoot.querySelector('.swiper') || slider.querySelector('.swiper'); if (swiperElement && swiperElement.swiper) { swiperElement.swiper.params.speed = 800; swiperElement.swiper.slideNext(800); return; } /* Safe fallback: click next pagination bullet */ const bullets = Array.from( sliderRoot.querySelectorAll('.swiper-pagination-bullet') ); if (!bullets.length) return; const current = bullets.findIndex( bullet => bullet.classList.contains( 'swiper-pagination-bullet-active' ) ); const next = current === -1 ? 0 : (current + 1) % bullets.length; bullets[next]?.click(); } let timer = null; function start() { clearInterval(timer); timer = setInterval(nextSlide, DELAY); } function stop() { clearInterval(timer); } host.addEventListener('mouseenter', stop); host.addEventListener('mouseleave', start); host.addEventListener( 'touchstart', stop, { passive: true } ); host.addEventListener( 'touchend', function () { setTimeout(start, 1500); }, { passive: true } ); document.addEventListener( 'visibilitychange', function () { if (document.hidden) { stop(); } else { start(); } } ); start(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })(); document.addEventListener('DOMContentLoaded', function () { const links = document.querySelectorAll('a'); links.forEach(function (link) { if (link.textContent.trim() === 'عرض الكل') { link.href = '/hair-care-products/c270189467'; } }); }); document.addEventListener('DOMContentLoaded', function () { const startYear = 2023; const currentYear = new Date().getFullYear(); const copyrightLinks = document.querySelectorAll( 'a[href="https://cham-soc.com"], a[href="https://cham-soc.com/"]' ); copyrightLinks.forEach(function (link) { const paragraph = link.closest('p'); if (!paragraph || !paragraph.textContent.includes('جميع الحقوق محفوظة')) { return; } paragraph.innerHTML = ` جميع الحقوق محفوظة © ${startYear} - ${currentYear} Chăm Sóc | صنع بواسطة Scope Arab `; }); });