// Also add the LinkedIn icon with the same retry approach function addLinkedInIcon() { const socialList = document.querySelector('salla-social.s-social-list'); if (socialList) { // Check if LinkedIn is already added to avoid duplicates const existingLinkedIn = socialList.querySelector('a[href*="linkedin.com"]'); if (existingLinkedIn) { console.log('LinkedIn icon already exists'); return true; } const linkedinHTML = ` `; socialList.insertAdjacentHTML('beforeend', linkedinHTML); console.log('LinkedIn icon added successfully'); return true; } console.log('Social list not found'); return false; } // Try adding the LinkedIn icon with the same retry approach document.addEventListener('DOMContentLoaded', function() { // Try immediately if (addLinkedInIcon()) return; // Try a few more times with delays setTimeout(function() { if (addLinkedInIcon()) return; setTimeout(addLinkedInIcon, 1000); }, 500); }); /***************************/ // البحث عن فورم المنتج const productForm = document.querySelector('.product-single form.form.product-form'); if (productForm) { // إنشاء div الحاوي const whatsappDiv = document.createElement('div'); whatsappDiv.style.cssText = ` margin-top: 20px; padding: 15px; text-align: center; border: 1px solid #e0e0e0; border-radius: 8px; background-color: #f9f9f9; `; // إنشاء النص const whatsappText = document.createElement('p'); whatsappText.textContent = ' للحجز و الاستفسار'; whatsappText.style.cssText = ` margin: 0 0 15px 0; color: #333; font-size: 19px; font-weight: 700; `; // إنشاء زرار الواتساب const whatsappButton = document.createElement('button'); whatsappButton.textContent = 'طلب عبر الواتساب'; whatsappButton.style.cssText = ` background-color: #25D366; color: white; border: none; padding: 12px 24px; border-radius: 25px; font-size: 16px; font-weight: bold; cursor: pointer; transition: background-color 0.3s ease; display: inline-flex; align-items: center; gap: 8px; `; // إضافة أيقونة الواتساب whatsappButton.innerHTML = ` طلب عبر الواتساب `; // إضافة تأثير hover whatsappButton.addEventListener('mouseenter', function() { this.style.backgroundColor = '#128C7E'; }); whatsappButton.addEventListener('mouseleave', function() { this.style.backgroundColor = '#25D366'; }); // إضافة وظيفة الضغط على الزرار whatsappButton.addEventListener('click', function() { const phoneNumber = '966502137745'; const message = 'مرحباً، أريد الاستفسار عن المنتج'; const whatsappUrl = `https://wa.me/${phoneNumber}?text=${encodeURIComponent(message)}`; window.open(whatsappUrl, '_blank'); }); // إضافة العناصر إلى div whatsappDiv.appendChild(whatsappText); whatsappDiv.appendChild(whatsappButton); // إدراج div بعد الفورم productForm.parentNode.insertBefore(whatsappDiv, productForm.nextSibling); } /******/ // التحقق من الشروط المطلوبة function shouldShowBanner() { // التحقق من body.index const isIndexPage = document.body?.classList.contains('index'); // التحقق من الـ canonical link const canonicalLink = document.querySelector('link[rel="canonical"][href*="دورة-تحقيقات-حوادث-الطائرات-والمطارات"]'); return isIndexPage || canonicalLink; } // التحكم في الشريط function controlBanner() { const banner = document.querySelector('salla-advertisement'); if (banner && !shouldShowBanner()) { banner.remove(); // حذف الشريط نهائياً من الصفحات غير المطلوبة } } // تشغيل الكود فوراً عند التحميل (function() { // تشغيل فوري controlBanner(); // تشغيل عند اكتمال تحميل DOM if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', controlBanner); } // تشغيل إضافي بعد تأخير بسيط للتأكد من تحميل العناصر setTimeout(controlBanner, 100); })();