document.addEventListener("DOMContentLoaded", function() { const wrapper = document.querySelector('.enhanced_links_wrapper'); const originalList = document.querySelector('.store-links-items'); if (wrapper && originalList) { // إنشاء الحاوية الرئيسية (تقسم يمين ويسار) const flexContainer = document.createElement('div'); flexContainer.style.display = 'flex'; flexContainer.style.justifyContent = 'space-between'; flexContainer.style.flexWrap = 'wrap'; flexContainer.style.gap = '20px'; // إعداد قائمة اليمين (السياسات) const rightList = document.createElement('ul'); rightList.className = originalList.className; rightList.style.flex = '1'; rightList.style.minWidth = '150px'; // إجبار العناصر لتكون تحت بعضها rightList.style.display = 'flex'; rightList.style.flexDirection = 'column'; rightList.style.gap = '15px'; // مسافة متساوية بين الروابط // إعداد قائمة اليسار (من نحن والأسئلة) const leftList = document.createElement('ul'); leftList.className = originalList.className; leftList.style.flex = '1'; leftList.style.minWidth = '150px'; // إجبار العناصر لتكون تحت بعضها leftList.style.display = 'flex'; leftList.style.flexDirection = 'column'; leftList.style.gap = '15px'; // مسافة متساوية بين الروابط // فرز العناصر const listItems = Array.from(originalList.querySelectorAll('li')); listItems.forEach(item => { // إزالة أي تنسيق قديم يجعلها أفقية item.style.display = 'block'; item.style.width = '100%'; const linkText = item.textContent.trim(); if (linkText.includes('سياسة')) { rightList.appendChild(item); } else { leftList.appendChild(item); } }); // إضافة القوائم للحاوية flexContainer.appendChild(rightList); flexContainer.appendChild(leftList); // استبدال القديم بالجديد المنسق wrapper.replaceChild(flexContainer, originalList); } }); // 1. تخزين الكود مع إضافة معرّف فريد (custom-social-icons) لضمان عدم التكرار const socialMediaHTML = ` `; // 2. شرط التحقق: لن يتم التنفيذ إلا إذا لم يجد العنصر الذي يحمل ID "custom-social-icons" if (!document.getElementById('custom-social-icons')) { // 3. البحث عن الحاوية (Container) الخاصة بالفوتر const footerSection = document.querySelector('.mb-2\\.5.col-span-2'); if (footerSection) { // العثور على جميع فقرات النص داخل الحاوية const paragraphs = footerSection.querySelectorAll('p'); let targetParagraph = null; // البحث بالتحديد عن الفقرة المطلوبة for (let p of paragraphs) { if (p.textContent.includes('اختيارات تعكس الأناقة الهادئة في كل تفصيل')) { targetParagraph = p; break; } } // إذا تم العثور على الفقرة، أضف الكود، وإلا جرب الحل البديل if (targetParagraph) { targetParagraph.insertAdjacentHTML('afterend', socialMediaHTML); } else { const footerBadges = footerSection.querySelector('.footer-badges'); if (footerBadges) { footerBadges.insertAdjacentHTML('beforebegin', socialMediaHTML); } } } } (function() { // نستخدم مؤقت للبحث عن العناصر باستمرار حتى يكتمل تحميل صفحة سلة بالكامل let attempts = 0; const interval = setInterval(function() { attempts++; const footerTitles = document.querySelectorAll('.footer-title'); let targetTitle = null; // 1. البحث عن عنوان "روابط مهمة" footerTitles.forEach(function(title) { if (title.textContent.trim().includes('روابط مهمة')) { targetTitle = title; } }); // إذا تم العثور على القسم، نبدأ التعديل if (targetTitle) { clearInterval(interval); // إيقاف البحث بمجرد العثور عليه // تغيير الاسم إلى "السياسات" targetTitle.textContent = 'السياسات'; // تحديد الحاوية الأب للقسم بالكامل const policiesDiv = targetTitle.parentElement.parentElement; if (policiesDiv) { // 2. حذف روابط "من نحن" و "الأسئلة الشائعة" const links = policiesDiv.querySelectorAll('a'); links.forEach(function(link) { const text = link.textContent.trim(); if (text === 'من نحن' || text === 'الأسئلة الشائعة') { const liItem = link.closest('li'); if (liItem) liItem.remove(); // حذف العنصر } }); // 3. إنشاء قسم "الروابط المهمة" الجديد بالروابط المطلوبة مع القائمة المنسدلة if (!document.getElementById('custom-important-links')) { const newLinksHTML = ` `; // إدراج القسم الجديد بجوار قسم السياسات policiesDiv.insertAdjacentHTML('afterend', newLinksHTML); } } } else if (attempts > 20) { // إيقاف البحث بعد 10 ثوانٍ (20 محاولة) لتجنب استهلاك المتصفح في حال لم يوجد العنصر clearInterval(interval); } }, 500); // تكرار الفحص كل نصف ثانية })(); (function() { let attempts = 0; // استخدام مؤقت للتأكد من تحميل العناصر بالكامل const interval = setInterval(function() { attempts++; const socialContainer = document.getElementById('custom-social-icons'); if (socialContainer) { // البحث عن جميع القوائم داخل حاوية التواصل الاجتماعي const socialLists = socialContainer.querySelectorAll('ul.s-social-list'); // إذا وجد الكود أكثر من قائمة (أي يوجد تكرار)، سيقوم بحذف القائمة الثانية if (socialLists.length > 1) { // حذف القائمة المكررة (الترتيب البرمجي يبدأ من 0، لذا 1 هي القائمة الثانية) socialLists[1].remove(); clearInterval(interval); // إيقاف الكود بعد التنفيذ بنجاح } } // إيقاف المحاولات بعد 10 ثوانٍ (20 محاولة) لتخفيف الحمل على المتصفح if (attempts > 20) { clearInterval(interval); } }, 500); })();