export const getChapterCount = async (nativeTitle: string): Promise => { const html = new DOMParser().parseFromString( await (await fetch(`https://rawkuma.com/?s=${encodeURIComponent(nativeTitle)}`)).text(), 'text/html' ); const listContent = html.querySelector('.listupd'); if (listContent && listContent.textContent && listContent.textContent.includes('Not Found')) { return undefined; } const chapterCount = html.querySelector('.epxs'); if (chapterCount && chapterCount.textContent && chapterCount.textContent.includes('Chapter')) { return Number.parseInt(chapterCount.textContent.replace('Chapter', '').trim(), 10); } return undefined; };