// 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); })(); // ************ (function () { function run() { var body = document.body; // التأكد من الشرط: body.product-single:has(#product-2113219870) if (!body.classList.contains('product-single')) return; if (!body.querySelector('#product-2113219870')) return; // البحث عن كل العناصر اللي فيها النص المطلوب document.querySelectorAll('.px-4.\\!text-red-800').forEach(function (el) { el.childNodes.forEach(function (node) { if (node.nodeType === Node.TEXT_NODE && node.textContent.includes('تم شراءه')) { node.textContent = node.textContent.replace('تم شراءه', 'تم حجزه'); } }); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', run); } else { run(); } })(); // ********* (function () { const phone = '966502137745'; const targetId = '2113219870'; function injectButton(card) { if (!card || card.dataset.waInjected) return; const footer = card.querySelector('.s-product-card-content-footer'); const titleLink = card.querySelector('.s-product-card-content-title a'); if (!footer || !titleLink) return; const productName = titleLink.textContent.trim(); const message = encodeURIComponent('اريد الاستفسار عن ' + productName); const waLink = 'https://api.whatsapp.com/send/?phone=' + phone + '&text=' + message; const btn = document.createElement('a'); btn.href = waLink; btn.target = '_blank'; btn.rel = 'noopener'; btn.className = 's-button-element s-button-btn s-button-outline s-button-wide s-button-primary-outline'; btn.style.marginTop = '8px'; btn.innerHTML = ' تواصل معنا'; footer.appendChild(btn); card.dataset.waInjected = 'true'; // منع التكرار } function tryInject() { const card = document.getElementById(targetId); if (card) injectButton(card); } // محاولة فورية لو العنصر موجود بالفعل tryInject(); // مراقبة أي تغييرات في الصفحة (لأن الكارت بيتحمّل ديناميكيًا) const observer = new MutationObserver(tryInject); observer.observe(document.body, { childList: true, subtree: true }); })();