/* Growth navigation and presentation. */ (()=>{'use strict'; if(!(['growthroaster.com','www.growthroaster.com'].includes(location.hostname)||(location.hostname==='salla.sa'&&location.pathname.startsWith('/ffd0d7b2-be78-4834-91c3-3c6fc0528bc9'))))return; function mount(){ const header=document.querySelector('header.store-header');if(!header)return; if(!document.getElementById('growth-native-nav')){ const nav=document.createElement('nav');nav.id='growth-native-nav';nav.className='growth-native-nav';nav.setAttribute('aria-label','أقسام قروث'); const home=header.querySelector('a.navbar-brand')?.href;if(!home)return; const base=home.replace(/\/$/,''); const links=[['الرئيسية',home],['محاصيل القهوة',base+'/category/VRQEgb'],['المحاصيل الفاخرة',base+'/category/lRgDbD'],['أظرف القهوة',base+'/category/YeqQPW'],['البوكسات والهدايا',base+'/-/c939566399'],['بوكس التذوق',base+'/#growth-bundle'],['عن قروث','#growth-about']]; links.push(['مبيعات الجملة','https://wa.me/966554548646']); for(const [label,href] of links){const a=document.createElement('a');a.textContent=label;a.href=href;if(href.startsWith('https://wa.me/')){a.target='_blank';a.rel='noopener';}nav.appendChild(a);} header.appendChild(nav); const dialog=document.createElement('dialog');dialog.id='growth-about';dialog.className='growth-about-dialog'; dialog.innerHTML='

عن قروث

محمصة قروث في المدينة المنورة. محاصيل قهوة مختصة من مناشئ متنوعة، وأظرف ترشيح وبوكسات لاكتشاف النكهات ومشاركتها.

الاستلام من فرع محمصة قروث في حي الدفاع.

موقع الاستلام على خرائط Google ↗'; document.body.appendChild(dialog); nav.querySelector('a[href$="#growth-bundle"]').addEventListener('click',e=>{const box=document.getElementById('growth-bundle');if(box){e.preventDefault();history.replaceState(null,'','#growth-bundle');box.scrollIntoView({behavior:'smooth',block:'start'});}}); nav.querySelector('a[href="#growth-about"]').addEventListener('click',e=>{e.preventDefault();dialog.showModal();}); } } if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',mount,{once:true});else mount(); const observer=new MutationObserver(()=>mount());observer.observe(document.documentElement,{childList:true,subtree:true});setTimeout(()=>observer.disconnect(),15000); })(); /* Growth sampler: 3 or 5 whole-bean crops, 250g each, native Salla cart. */ (()=>{'use strict'; const previewHost=(['growthroaster.com','www.growthroaster.com'].includes(location.hostname)||(location.hostname==='salla.sa'&&location.pathname.startsWith('/ffd0d7b2-be78-4834-91c3-3c6fc0528bc9'))); if(!previewHost)return; const products=[{"id": 79389685, "name": "إثيوبي قوجي", "price": 48, "image": "https://cdn.files.salla.network/products/284195285/1c95b777-1c8e-4b88-b5c6-87a919375fe0-original.webp", "tier": "standard", "note": "خوخ، كراميل، توت"}, {"id": 436014834, "name": "أوغندي مسابا", "price": 46, "image": "https://cdn.files.salla.network/products/284195285/4074863e-57dc-49db-affa-5f822cf8625c-original.webp", "tier": "premium", "note": "توت، فانيليا، برقوق، عنب"}, {"id": 544121335, "name": "كولومبيا هويلا", "price": 42, "image": "https://cdn.files.salla.network/products/284195285/6022cf67-c681-44f3-8f75-3a20d7e31d11-original.webp", "tier": "standard", "note": "سكر بني، شوكولاتة، كراميل، جريب فروت"}, {"id": 549286460, "name": "إثيوبي هاديسو", "price": 49, "image": "https://cdn.salla.sa/rArvxw/8005c767-ce1e-433c-b091-4a75e89f88b2-1000x1000-msa9x8Qhgvn142S8y6DmCurKlqdQ8pFFAfWygBQd.png", "tier": "premium", "note": "عنب، فراولة"}, {"id": 609053937, "name": "كولومبيا توليما", "price": 43, "image": "https://cdn.files.salla.network/products/284195285/58d908ef-362c-4f09-9f44-91af312348fd-original.webp", "tier": "standard", "note": "سكر بني، فواكه مجففة، قشر الليمون"}, {"id": 790530325, "name": "إثيوبي أنيروبيك همبيلا", "price": 59, "image": "https://cdn.salla.sa/rArvxw/232678ef-dec9-4f2d-ac3a-ea63a5509a81-1000x1000-PhbjwhlxDEepIy2OIedLQnJCLodoYkcAro5FVJEx.png", "tier": "reserve", "note": "مانجو، أناناس، كرز"}, {"id": 929919236, "name": "إثيوبي شاكيسو", "price": 47, "image": "https://cdn.files.salla.network/other/284195285/7d2d513a-db6c-4f4f-9d0f-98c4f86b46f2-original.webp", "tier": "premium", "note": "عسل، فواكه، مذاق نظيف"}, {"id": 1418212548, "name": "إثيوبي همبيلا", "price": 44, "image": "https://cdn.files.salla.network/products/284195285/77490472-86e6-4dbd-a854-82eab28ed2d7-original.webp", "tier": "standard", "note": "خوخ، توت"}, {"id": 1451328246, "name": "إثيوبي ننسيبو", "price": 46, "image": "https://cdn.files.salla.network/products/284195285/ab89cf85-5881-49b2-8f1f-9d30aaf3c24f-original.webp", "tier": "premium", "note": "عنب أسود، شوكولاتة، تين"}, {"id": 1624960427, "name": "إثيوبي أوراقا", "price": 48, "image": "https://cdn.salla.sa/rArvxw/abc1aae2-a6fc-4ce0-bd62-292fff5ec9b2-1000x1000-uKMYaxPRa5yjhzGAPWwcB8itqyUnd5AlP537mfgJ.png", "tier": "premium", "note": "شوكولاتة، مكسرات، أزهار، ليمون"}, {"id": 1634372350, "name": "برازيلي فازيندا", "price": 40, "image": "https://cdn.files.salla.network/products/284195285/c400fa1d-4c02-491b-8593-8bda8563f9e2-original.webp", "tier": "standard", "note": "شوكولاتة، كراميل، مكسرات"}, {"id": 1672039633, "name": "إثيوبي تشيلتشيلي", "price": 47, "image": "https://cdn.files.salla.network/products/284195285/3004540f-fd1f-4a29-8605-674735586572-original.webp", "tier": "premium", "note": "فاكهية، حلوة، شاي، زهرية"}, {"id": 1813598748, "name": "أوغندي بوجوكو", "price": 48, "image": "https://cdn.salla.sa/rArvxw/1a85f8eb-6c57-4d2b-87e9-fef27ddd7e0e-1000x1000-gPhljxyo9ATzFvu6SklMf3C93Je3uSnzD4DidbR8.png", "tier": "standard", "note": "سكر بني، كاكاو"}, {"id": 1910819723, "name": "أوغندي ماناناسي", "price": 49, "image": "https://cdn.salla.sa/rArvxw/fbf00179-b313-4279-affa-3c612cac0d84-1000x1000-JuOruNnRf341gjOYgLiv5XCEdnSlVNYvl3IHbkvh.png", "tier": "standard", "note": "مشمش، مانجو، شوكولاتة داكنة"}, {"id": 709442074, "name": "أوغندا زيوا", "price": 42, "image": "https://cdn.files.salla.network/other/284195285/63f058ed-6523-4858-85dc-3062346f0c58-original.webp", "tier": "standard", "note": "شوكولاتة بالحليب، كراميل، زهور، موز، توابل بنية، عنب"}, {"id": 1917567216, "name": "سلفادور سانتا", "price": 42, "image": "https://cdn.files.salla.network/products/284195285/84c3c525-2528-45c6-8372-5eab1381c43d-original.webp", "tier": "standard", "note": "لوز، كاكاو، برقوق"}, {"id": 323422794, "name": "كيني مغسول", "price": 43, "image": "https://cdn.files.salla.network/other/284195285/2a9ce5e0-048c-4f73-b3b9-4a7e3c298946-original.webp", "tier": "standard", "note": "كشمش أسود، توت أحمر، حمضيات، سكر بني"}, {"id": 249436507, "name": "يمني فاخر حراز", "price": 79, "image": "https://cdn.files.salla.network/other/284195285/83d45d4e-c7bd-41bf-9083-cc0c2ebca464-original.webp", "tier": "signature", "note": "زهور، فواكه استوائية"}, {"id": 430375075, "name": "كولومبي معزز بنكهة فراولة", "price": 79, "image": "https://cdn.files.salla.network/other/284195285/0d4cbca0-1e10-407d-828c-a4c6f144e37e-original.webp", "tier": "reserve", "note": "فراولة"}, {"id": 214354601, "name": "كولومبي سنجاريا — العنب", "price": 79, "image": "https://cdn.files.salla.network/other/284195285/c13836e6-897a-4310-8a38-037b6741ab38-original.webp", "tier": "reserve", "note": "عنب"}, {"id": 820010430, "name": "يمني حراز — تخمير مشترك بالهيل", "price": 91, "image": "https://cdn.files.salla.network/other/284195285/13e55402-00da-4ddb-8a61-e537f1da1d41-original.webp", "tier": "reserve", "note": "هيل"}, {"id": 1870431104, "name": "كولومبيا إل تابور", "price": 58, "image": "https://cdn.files.salla.network/other/284195285/2d14e5e8-c171-4586-8dca-b29fba770db3-original.webp", "tier": "signature", "note": "عسل، باشن فروت، توت العليق"}, {"id": 329127573, "name": "إثيوبي أوراقا — نبيذ العنب", "price": 89, "image": "https://cdn.files.salla.network/other/284195285/eafcb7ad-c192-4e8c-9f24-b0aa7e520748-original.webp", "tier": "signature", "note": "عنب"}, {"id": 1311333535, "name": "البرازيل كارمو ميناس", "price": 45, "image": "https://cdn.files.salla.network/other/284195285/2b003d16-9098-43e8-8ddb-a933a72a28f3-original.webp", "tier": "signature", "note": "شوكولاتة بالحليب، بندق"}, {"id": 719283168, "name": "رواندا هويي قيشامفو", "price": 56, "image": "https://cdn.files.salla.network/other/284195285/c89b5fb3-c316-4005-8cf3-5f14e839562c-original.webp", "tier": "signature", "note": "فواكه صفراء، مانجو، كراميل"}, {"id": 395217641, "name": "إثيوبيا قوجي بنتي ننكا", "price": 54, "image": "https://cdn.files.salla.network/other/284195285/0b7a6166-8a45-4afc-8255-edd5260892c2-original.webp", "tier": "signature", "note": "خوخ ناضج، لمحات فواكه استوائية"}, {"id": 1774452477, "name": "كولومبيا تانجرين برتقال يوسفي", "price": 88, "image": "https://cdn.files.salla.network/other/284195285/fffba401-1eb6-48ae-babe-c2ab8b49f91a-original.webp", "tier": "reserve", "note": "يوسفي، ماندارين، برتقال حلو"}]; const base=document.querySelector('a.navbar-brand')?.href.replace(/\/$/,'');if(!base)return; const homePath=new URL(base).pathname.replace(/\/$/,'');if(location.pathname.replace(/\/$/,'')!==homePath)return; let busy=false,finished=false,filter='all';const selected=new Set(); const esc=s=>String(s??'').replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); const money=n=>new Intl.NumberFormat('ar-SA',{maximumFractionDigits:2}).format(n)+' ريال'; const limit=(promise)=>Promise.race([promise,new Promise((_,reject)=>setTimeout(()=>reject(Error('تأخر تأكيد سلة. راجع السلة قبل إعادة المحاولة.')),20000))]); async function check(p){const r=await limit(salla.product.getDetails(p.id,['options']));if(!r.success||!r.data)throw Error('تعذر التحقق من '+p.name);const d=r.data;if(d.is_available===false)throw Error(p.name+' غير متاح حاليًا');if(Array.isArray(d.options)&&d.options.length)throw Error(p.name+' يحتاج اختيار خيارات من صفحة المنتج');const q=await limit(salla.product.getPrice({id:p.id,quantity:1}));if(!q.success||!Number.isFinite(Number(q.data?.price)))throw Error('تعذر تأكيد سعر '+p.name);return {price:Number(q.data.price),available:d.is_available,options:(d.options||[]).length,weight:d.weight_label||d.weight};} function mount(){const main=document.querySelector('main');if(!main||document.getElementById('growth-bundle'))return; const style=document.createElement('style');style.textContent=`#growth-bundle{max-width:1240px;margin:48px auto;padding:32px 20px;background:#fffaf1;color:#40261e;border:1px solid #ddccb4;border-radius:18px;scroll-margin-top:110px}#growth-bundle h2{font-size:30px;font-weight:800;color:#234c35;margin:0 0 12px}#growth-bundle p{line-height:1.9}#growth-bundle .gb-tools{display:flex;gap:12px;flex-wrap:wrap;align-items:center;margin:20px 0}#growth-bundle select,#growth-bundle input[type=search]{padding:12px;border:1px solid #b7a181;border-radius:8px;background:white;color:#234c35}#growth-bundle input[type=search]{flex:1;min-width:160px}#growth-bundle .gb-tabs{display:flex;gap:8px;flex-wrap:wrap}#growth-bundle button{padding:10px 17px;border-radius:8px;border:1px solid #234c35;background:#fffaf1;color:#234c35;font-weight:700}#growth-bundle button[aria-pressed=true],#growth-bundle #growth-box-send{background:#234c35;color:white}#growth-bundle button:disabled{opacity:.45;cursor:not-allowed}#growth-box-options{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:14px;margin:24px 0}#growth-bundle .gb-card{position:relative;border:1px solid #ddccb4;border-radius:10px;padding:8px;background:#fff;display:flex;flex-direction:column;gap:8px;cursor:pointer}#growth-bundle .gb-card:has(input:checked){outline:3px solid #234c35}#growth-bundle .gb-card[hidden]{display:none}#growth-bundle .gb-card img{width:100%;aspect-ratio:1;object-fit:contain;border-radius:6px}#growth-bundle .gb-card input{accent-color:#234c35;width:19px;height:19px}#growth-bundle .gb-card strong{font-size:14px}#growth-bundle .gb-note{font-size:11px;line-height:1.7;color:#79634e;min-height:35px}#growth-bundle .gb-price{color:#234c35;font-weight:800}#growth-bundle .gb-star{color:#9e7427;font-size:12px}#growth-bundle .gb-summary{position:static;background:#f1e8d6;padding:18px;border:1px solid #c7b187;border-radius:12px;box-shadow:0 5px 20px #0002}#growth-box-slots{display:flex;gap:8px;margin-bottom:12px;flex-wrap:wrap}#growth-box-slots img{width:64px;height:64px;border-radius:6px;object-fit:contain}#growth-bundle .gb-empty{width:64px;height:64px;border:1px dashed #9a8669;display:grid;place-items:center;border-radius:6px;color:#9a8669}#growth-bundle .gb-actions{display:flex;gap:14px;align-items:center;flex-wrap:wrap}#growth-box-status{margin:8px 0 0}#growth-bundle details{margin-top:20px;font-size:12px}#growth-bundle pre{white-space:pre-wrap;direction:rtl}#growth-box-total{font-size:20px;font-weight:800} @media(max-width:900px){#growth-box-options{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:550px){#growth-bundle{margin:24px 10px;padding:20px 12px}#growth-box-options{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}#growth-bundle h2{font-size:24px}#growth-bundle .gb-summary{bottom:4px;padding:12px}#growth-box-slots img,#growth-bundle .gb-empty{width:45px;height:45px}}`; document.head.append(style);const panel=document.createElement('section');panel.id='growth-bundle';panel.dir='rtl';panel.innerHTML=`

بوكس التذوق — اختياراتك على ذوقك

اختر ٣ أو ٥ محاصيل من قروث. كل كيس ٢٥٠ جرام من الحبوب الكاملة، والسعر هو مجموع المحاصيل التي تختارها.

مراجعة السلة

`;const anchor=main.querySelector('#best-offers-5-slider');if(anchor)anchor.after(panel);else main.append(panel); const q=id=>document.getElementById(id),options=q('growth-box-options');for(const p of products){const label=document.createElement('label');label.className='gb-card';label.dataset.id=p.id;label.innerHTML=`${esc(p.name)} ${esc(p.name)}${esc(p.note)}${p.tier==='reserve'?'★ محصول فاخر':''}${money(p.price)}`;options.append(label);label.querySelector('input').onchange=e=>{e.target.checked?selected.add(p.id):selected.delete(p.id);update()};} function update(){const n=Number(q('growth-box-size').value),term=q('growth-box-search').value.trim();for(const p of products){const card=options.querySelector(`[data-id="${p.id}"]`),input=card.querySelector('input');input.disabled=busy||finished||(!input.checked&&selected.size>=n);card.hidden=(filter!=='all'&&p.tier!==filter)||(term&&!`${p.name} ${p.note}`.includes(term));card.querySelector('[data-price]').textContent=money(p.price);}q('growth-box-size').disabled=busy||finished;q('growth-box-send').disabled=busy||finished||selected.size!==n;q('growth-box-total').textContent=`${selected.size} من ${n} · ${money(products.filter(p=>selected.has(p.id)).reduce((s,p)=>s+p.price,0))} شامل الضريبة`;const chosen=products.filter(p=>selected.has(p.id));q('growth-box-slots').innerHTML=chosen.map(p=>`${esc(p.name)}`).join('')+Array.from({length:n-chosen.length},()=>'+').join('');} panel.querySelectorAll('[data-filter]').forEach(b=>b.onclick=()=>{filter=b.dataset.filter;panel.querySelectorAll('[data-filter]').forEach(t=>t.setAttribute('aria-pressed',String(t===b)));update()});q('growth-box-search').oninput=update;q('growth-box-size').onchange=()=>{selected.clear();options.querySelectorAll('input').forEach(i=>i.checked=false);update()}; q('growth-box-send').onclick=async()=>{if(busy||finished||selected.size!==Number(q('growth-box-size').value))return;busy=true;update();const chosen=products.filter(p=>selected.has(p.id));let attempted=false,added=0;try{q('growth-box-status').textContent='نتحقق من الأسعار والتوفر...';let changed=false;for(const p of chosen){const d=await check(p);if(d.price!==p.price){p.price=d.price;changed=true;}}if(changed){q('growth-box-status').textContent='تحدثت الأسعار حسب سلة. راجع المجموع ثم اضغط الإضافة للتأكيد.';return;}const notes='بوكس تذوق '+chosen.length+' محاصيل | حبوب كاملة | 250 جرام لكل محصول | '+chosen.map(p=>p.name).join('، ');for(const p of chosen){attempted=true;q('growth-box-status').textContent='نضيف '+p.name+' إلى السلة...';const r=await limit(salla.cart.addItem({id:p.id,quantity:1,notes}));if(!r.success)throw Error('لم تؤكد سلة إضافة '+p.name);added++;}finished=true;q('growth-box-status').textContent='تمت إضافة محاصيل البوكس. راجع السلة لإكمال طلبك.';}catch(e){finished=attempted;q('growth-box-status').textContent=(e.message||'تعذر إكمال الإضافة')+(attempted?' — تمت إضافة '+added+' محاصيل مؤكدًا. راجع السلة قبل إعادة المحاولة.':'');}finally{busy=false;update()}}; update(); function scrollToBox(){if(location.hash==='#growth-bundle')panel.scrollIntoView({block:'start'});} window.addEventListener('hashchange',scrollToBox); requestAnimationFrame(scrollToBox); } if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',mount,{once:true});else mount();})(); /* Growth conversion presentation — 15 October 2026. Append after the preserved sampler. */ (() => { 'use strict'; const allowedHost = ['growthroaster.com', 'www.growthroaster.com'].includes(location.hostname) || (location.hostname === 'salla.sa' && location.pathname.startsWith('/ffd0d7b2-be78-4834-91c3-3c6fc0528bc9')); if (!allowedHost || window.__growthConversion20261015) return; window.__growthConversion20261015 = true; // Names, tasting notes and images copied from the published catalogue. No duplicated prices. const picks = [ { id: 1634372350, name: 'برازيلي فازيندا', taste: 'للشوكولاتة والمكسرات', note: 'شوكولاتة، كراميل، مكسرات', href: 'https://growthroaster.com/برازيلي-فازيندا-250-جرام/p1634372350', image: 'https://cdn.files.salla.network/products/284195285/c400fa1d-4c02-491b-8593-8bda8563f9e2-original.webp' }, { id: 544121335, name: 'كولومبيا هويلا', taste: 'للكراميل ولمسة الحمضيات', note: 'سكر بني، شوكولاتة، كراميل، جريب فروت', href: 'https://growthroaster.com/كولومبيا-هويلا-250-جرام/p544121335', image: 'https://cdn.files.salla.network/products/284195285/6022cf67-c681-44f3-8f75-3a20d7e31d11-original.webp' }, { id: 79389685, name: 'إثيوبي قوجي', taste: 'للخوخ والتوت', note: 'خوخ، كراميل، توت', href: 'https://growthroaster.com/إثيوبي-قوجي-250-جرام/p79389685', image: 'https://cdn.files.salla.network/products/284195285/1c95b777-1c8e-4b88-b5c6-87a919375fe0-original.webp' } ]; const escapeHTML = value => String(value).replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[char])); const cleanText = value => String(value || '').replace(/\u00a0/g, ' ').replace(/[\t ]+/g, ' ').trim(); function nativeProductLink(main, productId) { for (const anchor of main.querySelectorAll('a[href]')) { if (anchor.closest('#growth-conversion-picks')) continue; try { const url = new URL(anchor.href, location.href); if (new RegExp('/p' + productId + '/?$').test(url.pathname) && ['growthroaster.com', 'www.growthroaster.com', location.hostname].includes(url.hostname)) { return url.href; } } catch (_) { /* Ignore malformed unrelated links. */ } } return ''; } function mountHome(main) { const brand = document.querySelector('a.navbar-brand'); if (!brand) return; let homePath; try { homePath = new URL(brand.href).pathname.replace(/\/$/, ''); } catch (_) { return; } if (location.pathname.replace(/\/$/, '') !== homePath) return; let hero = document.getElementById('growth-conversion-hero'); if (!hero) { hero = document.createElement('section'); hero.id = 'growth-conversion-hero'; hero.dir = 'rtl'; hero.setAttribute('aria-labelledby', 'growth-conversion-title'); hero.innerHTML = '

محمصة قروث

' + '

ابدأ من النكهة
اللي تحبها

' + '

محاصيل مختصة بإيحاءات متنوعة. اختر النكهة الأقرب لك، أو كوّن بوكس التذوق من ٣ أو ٥ محاصيل.

' + '
شوف الترشيحات' + 'كوّن بوكسك
'; const heroProduct = document.createElement('img'); heroProduct.className = 'gc-hero-product'; heroProduct.src = picks[0].image; heroProduct.alt = ''; heroProduct.setAttribute('aria-hidden', 'true'); heroProduct.width = 320; heroProduct.height = 320; heroProduct.decoding = 'async'; hero.appendChild(heroProduct); main.prepend(hero); } let choices = document.getElementById('growth-conversion-picks'); if (!choices) { choices = document.createElement('section'); choices.id = 'growth-conversion-picks'; choices.dir = 'rtl'; choices.setAttribute('aria-labelledby', 'growth-conversion-picks-title'); choices.innerHTML = '

اختيارات تساعدك تبدأ

' + '

أي نكهة أقرب لذوقك؟

' + '

ثلاثة محاصيل بإيحاءات مختلفة · حبوب كاملة · ٢٥٠ جم للكيس

'; for (const product of picks) { const href = nativeProductLink(main, product.id) || product.href; const card = document.createElement('a'); card.className = 'gc-pick'; card.dataset.productId = product.id; card.href = href || '#growth-bundle'; card.innerHTML = '' + escapeHTML(product.name)
          + '' + '
' + escapeHTML(product.taste) + '' + '

' + escapeHTML(product.name) + '

إيحاءات: ' + escapeHTML(product.note) + '

' + '' + (href ? 'شوف المحصول' : 'اختره ضمن بوكسك') + '
'; choices.querySelector('.gc-picks-grid').appendChild(card); } hero.after(choices); } // Upgrade a fallback link only when a matching native product link becomes available. for (const card of choices.querySelectorAll('.gc-pick')) { if (card.getAttribute('href') !== '#growth-bundle') continue; const href = nativeProductLink(main, card.dataset.productId); if (!href) continue; card.href = href; card.querySelector('.gc-pick-link').innerHTML = 'شوف المحصول '; } // Hide only the two replaced homepage image banners after a complete live-text hero exists. const banners = Array.from(main.children).filter(node => node.matches('section.s-block--fixed-banner')); banners.slice(0, 2).forEach(node => node.classList.add('growth-conversion-replaced-banner')); const categories = Array.from(main.children).find(node => node.matches('.s-block--banners')); if (categories) { categories.classList.add('growth-conversion-categories'); const categoryLabels = { '/-/c939566399': 'البوكسات والهدايا', '/-/c1849394750': 'محاصيل القهوة', '/-/c367903800': 'أظرف القهوة' }; for (const anchor of categories.querySelectorAll('a.banner-entry')) { let path; try { path = new URL(anchor.href, location.href).pathname.replace(/\/$/, ''); } catch (_) { continue; } const key = Object.keys(categoryLabels).find(suffix => path.endsWith(suffix)); if (!key) continue; anchor.setAttribute('aria-label', categoryLabels[key]); if (!anchor.querySelector('.gc-category-label')) { const label = document.createElement('span'); label.className = 'gc-category-label'; label.textContent = categoryLabels[key]; anchor.appendChild(label); } } if (choices.nextElementSibling !== categories) choices.after(categories); } const sampler = document.getElementById('growth-bundle'); if (sampler && categories && categories.nextElementSibling !== sampler) categories.after(sampler); if (sampler) { const options = sampler.querySelector('#growth-box-options'); if (options && !options.hasAttribute('tabindex')) { options.tabIndex = 0; options.setAttribute('aria-label', 'محاصيل بوكس التذوق؛ مرّر لعرض جميع المحاصيل'); } sampler.classList.add('growth-conversion-sampler'); } main.classList.add('growth-conversion-home'); } function descriptionLines(article) { const blocks = Array.from(article.querySelectorAll('p,h1,h2,h3,h4,h5,h6,li')); const source = blocks.length ? blocks : [article]; const lines = source.flatMap(node => (node.innerText || node.textContent || '').split(/[\n\r]+/)).map(cleanText).filter(Boolean); return lines.filter((line, index) => lines.indexOf(line) === index); } function mountProduct(main) { const description = main.querySelector('div[data-testid="store-product-description"].product__description'); const form = main.querySelector('.main-content form.product-form'); if (!description || !form || description.contains(form) || form.contains(description)) return; if (description.dataset.growthConversion === 'done') return; const article = description.querySelector('article.article--main'); if (!article || !cleanText(article.textContent)) return; const lines = descriptionLines(article); const facts = []; const flavorIndex = lines.findIndex(line => /^الإيحاءات(?:\s*[::]|\s*$)/.test(line)); if (flavorIndex >= 0) { let flavor = lines[flavorIndex]; if (/^الإيحاءات\s*[::]?\s*$/.test(flavor)) flavor += ' ' + (lines[flavorIndex + 1] || ''); if (flavor.length > 12 && flavor.length <= 180) facts.push(flavor); } // Copy the existing short line verbatim; do not infer size or grinding from a title or URL. const pack = lines.find(line => /حبوب (?:قهوة )?كاملة/.test(line) && /[0-9٠-٩]+\s*(?:جرام|غرام|جم|غ|g)(?:\s|$|[،·|.])/i.test(line) && line.length <= 180); if (pack) facts.push(pack); if (facts.length && !document.getElementById('growth-conversion-product-facts')) { const summary = document.createElement('div'); summary.id = 'growth-conversion-product-facts'; summary.className = 'growth-conversion-product-facts'; summary.setAttribute('aria-label', 'ملخص المحصول'); for (const fact of facts) { const paragraph = document.createElement('p'); paragraph.textContent = fact; summary.appendChild(paragraph); } form.before(summary); } for (const heading of article.querySelectorAll('h1,h2,h3,h4,h5,h6')) { const text = cleanText(heading.textContent); if (text.length <= 45 && /^(?:الإيحاءات|تفاصيل المحصول|معلومات المحصول|المواصفات|قصة المحصول|وصفة تحضير مقترحة|المعالجة|المنشأ|الارتفاع|الوزن|طريقة التحضير|مناسب لـ|مناسب ل|وصف المحصول|عن المحصول)(?:\s|[::]|$)/.test(text)) { heading.classList.add('gc-description-heading'); } } description.classList.add('growth-conversion-description'); if (form.nextElementSibling !== description) form.after(description); description.dataset.growthConversion = 'done'; main.classList.add('growth-conversion-product'); } let scheduled = false; let observer; function mount() { scheduled = false; const main = document.querySelector('main'); if (!main) return; mountHome(main); mountProduct(main); } function scheduleMount() { if (scheduled) return; scheduled = true; requestAnimationFrame(mount); } function start() { mount(); observer = new MutationObserver(scheduleMount); observer.observe(document.body, { childList: true, subtree: true }); setTimeout(() => observer.disconnect(), 15000); } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start, { once: true }); else start(); })();