/* Add custom Js code below */ function changeBackgroundColorAndAddLottie() { const elements = document.querySelectorAll('.s-product-card-promotion-title'); elements.forEach(element => { if (element.textContent.includes('توصيل مجاني') || element.textContent.includes('Free Delivery')) { element.style.setProperty('background-color', '#FB3568', 'important'); element.style.setProperty('max-height', '32px', 'important'); element.style.setProperty('white-space', 'nowrap', 'important'); // تحقق من عدم وجود dotlottie player مضاف بالفعل لتجنب التكرار if (!element.querySelector('dotlottie-player')) { const lottiePlayer = document.createElement('dotlottie-player'); lottiePlayer.setAttribute('src', 'https://lottie.host/2cbd65b5-9fe4-4351-94d0-330222ddc0cb/5vC1yugk01.json'); lottiePlayer.setAttribute('background', 'transparent'); lottiePlayer.setAttribute('speed', '1'); lottiePlayer.setAttribute('style', 'width: 24px; height: 24px; display: inline-flex; margin-right: 2px; margin-left: 2px; margin-bottom: 3px;'); lottiePlayer.setAttribute('loop', ''); lottiePlayer.setAttribute('autoplay', ''); element.appendChild(lottiePlayer); } } }); } // مراقب التغييرات على DOM const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.type === 'childList' || mutation.type === 'subtree') { changeBackgroundColorAndAddLottie(); } }); }); // خيارات المراقب const config = { childList: true, subtree: true }; // استهداف عنصر الجذر لمراقبة التغييرات observer.observe(document.body, config); // تطبيق التغييرات فور تحميل الصفحة لأول مرة document.addEventListener('DOMContentLoaded', (event) => { // تحميل الـ script مرة واحدة const script = document.createElement('script'); script.src = 'https://unpkg.com/@dotlottie/player-component@latest/dist/dotlottie-player.mjs'; script.type = 'module'; document.head.appendChild(script); // تطبيق التغييرات changeBackgroundColorAndAddLottie(); }); // إنشاء عنصر