blob: c570474d910a90f539777b8e36c44ee30ae62189 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import proxy from '$lib/Utility/proxy';
export const getChapterCount = async (nativeTitle: string): Promise<number | undefined> => {
const html = new DOMParser().parseFromString(
await (await fetch(proxy(`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;
};
|