// استبدل السكريبت في reader.html بهذا الكود async function loadChapter() { const urlParams = new URLSearchParams(window.location.search); const mangaId = urlParams.get('mangaId'); const ch = urlParams.get('ch'); if(!mangaId || !ch) return; document.getElementById('chapter-title').innerText = `فصل ${ch}`; try { const res = await fetch(`/api/chapter/images?mangaId=${mangaId}&ch=${ch}`); const images = await res.json(); if (images.length === 0) { document.getElementById('image-list').innerHTML = "

عذراً، لم نتمكن من العثور على صور هذا الفصل في السيرفر ❌

"; return; } const container = document.getElementById('image-list'); container.innerHTML = images.map(src => ``).join(''); } catch (e) { document.getElementById('image-list').innerHTML = "

فشل الاتصال بالسيرفر جراء حجم البيانات ❌

"; } } window.onload = loadChapter;