document.addEventListener('DOMContentLoaded', function () { // شغّل على الرئيسية فقط const onHome = location.pathname === '/' || /^\/(\?|$)/.test(location.pathname) || document.body.classList.contains('home') || document.body.classList.contains('homepage'); if (!onHome) return; // الروابط const links = [ { title: 'متاجر من تصميمنا', href: 'https://waarfe.com/%D9%85%D8%AA%D8%A7%D8%AC%D8%B1-%D9%85%D9%86-%D8%AA%D8%B5%D9%85%D9%8A%D9%85%D9%86%D8%A7/page-1607260519' }, { title: 'أراء عملائنا', href: 'https://waarfe.com/%D8%A3%D8%B1%D8%A7%D8%A1-%D8%B9%D9%85%D9%84%D8%A7%D8%A6%D9%8A/page-1526533301' }, { title: 'ماحصلت خدمتك ؟ اطلبها الان', href: 'https://waarfe.com/%D8%A7%D8%B7%D9%84%D8%A8-%D8%AE%D8%AF%D9%85%D8%AA%D9%83/page-1013007436' }, { title: 'دليل أنشطة وثيقة العمل الحر', href: 'https://waarfe.com/%D8%AF%D9%84%D9%8A%D9%84-%D8%A3%D9%86%D8%B4%D8%B7%D8%A9-%D9%88%D8%AB%D9%8A%D9%82%D8%A9-%D8%A7%D9%84%D8%B9%D9%85%D9%84-%D8%A7%D9%84%D8%AD%D8%B1/page-2098593800' }, ]; // CSS مرة واحدة if (!document.getElementById('waarfe-shortcuts-style')) { const style = document.createElement('style'); style.id = 'waarfe-shortcuts-style'; style.textContent = ` #waarfe-shortcuts{direction:rtl;max-width:1200px;margin:16px auto;padding:0 12px} #waarfe-shortcuts .grid{display:grid;gap:12px;justify-items:center} @media(min-width:768px){#waarfe-shortcuts .grid{grid-template-columns:repeat(3,1fr)}} #waarfe-shortcuts a{ display:flex;align-items:center;justify-content:center;text-align:center; padding:6px 12px;border-radius:14px;text-decoration:none;font-weight:700; background:#09382e;border:1px solid #0a453a;color:#fff; transition:transform .15s ease, box-shadow .15s ease, opacity .15s ease; width:auto; max-width:680px; min-width:300px; justify-self:center; } #waarfe-shortcuts a:hover{transform:translateY(-2px);box-shadow:0 8px 20px rgba(0,0,0,.10);opacity:.96} @media (max-width:767px){ #waarfe-shortcuts a{ max-width:420px; min-width:260px } } `; document.head.appendChild(style); } // يبني/يعيد استخدام الشريط function ensureSection(){ let section = document.getElementById('waarfe-shortcuts'); if (!section){ section = document.createElement('section'); section.id = 'waarfe-shortcuts'; section.innerHTML = `
${links.map(l => `${l.title}`).join('')}
`; } return section; } // ابحث عن صندوق العدادات (الكلاس الظاهر في لقطة الشاشة) function findCountersBox(){ let el = document.querySelector('.know-more-inner, [class*="know-more-inner"]'); if (el) return el; const all = Array.from(document.querySelectorAll('section,div,article')); const norm = s => (s||'').replace(/\s+/g,'').trim(); return all.find(node => { const t = norm(node.textContent); const matches = (t.match(/99\+?/g) || []).length; const score = ['عميل','تصميم','خدمة'].reduce((n,w)=> n + (t.includes(w)?1:0), 0); return matches >= 2 && score >= 2; }); } // ضع الشريط بعد العدادات function placeUnderCounters(){ const counters = findCountersBox(); if (!counters) return false; const section = ensureSection(); if (section.parentNode) section.parentNode.removeChild(section); const holder = counters.closest('section, .s-block, div') || counters; section.style.marginTop = '16px'; holder.insertAdjacentElement('afterend', section); return true; } // احتياط: إن فشل—بعد البنر function placeAfterHero(){ const hero = document.querySelector('.home-hero, .hero, .main-slider, .header-slider, .banner, .s-hero, salla-slider, .s-block-one-wide-banner'); if (!hero || !hero.parentNode) return false; const section = ensureSection(); if (section.parentNode) section.parentNode.removeChild(section); section.style.marginTop = '40px'; // ← تم تعديل المسافة هنا فقط hero.parentNode.insertBefore(section, hero.nextSibling); return true; } // نفّذ الآن ثم راقب DOM function tryPlace(){ if (placeUnderCounters()) return true; return placeAfterHero(); } if (!tryPlace()){ const obs = new MutationObserver(() => { if (tryPlace()) obs.disconnect(); }); obs.observe(document.documentElement, { childList:true, subtree:true }); setTimeout(()=>obs.disconnect(), 12000); } });