aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Data/Manga/raw.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-03-01 16:20:51 -0800
committerFuwn <[email protected]>2026-03-01 16:21:02 -0800
commiteae5d24d9e79e59a19d4721caaeaa0ca650ecb33 (patch)
tree1b685bb248e051dfa26d2bfdebe6689402dd93c5 /src/lib/Data/Manga/raw.ts
parentchore(tooling): remove legacy eslint and prettier (diff)
downloaddue.moe-eae5d24d9e79e59a19d4721caaeaa0ca650ecb33.tar.xz
due.moe-eae5d24d9e79e59a19d4721caaeaa0ca650ecb33.zip
chore(biome): drop formatter style overrides
Diffstat (limited to 'src/lib/Data/Manga/raw.ts')
-rw-r--r--src/lib/Data/Manga/raw.ts89
1 files changed, 54 insertions, 35 deletions
diff --git a/src/lib/Data/Manga/raw.ts b/src/lib/Data/Manga/raw.ts
index 4dfa6a8e..3663c737 100644
--- a/src/lib/Data/Manga/raw.ts
+++ b/src/lib/Data/Manga/raw.ts
@@ -1,47 +1,66 @@
-import proxy from '$lib/Utility/proxy';
+import proxy from "$lib/Utility/proxy";
interface Chapter {
- href: string;
- chapterNum: string;
- chapterDate: string;
+ href: string;
+ chapterNum: string;
+ chapterDate: string;
}
-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');
+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;
- }
+ if (
+ listContent &&
+ listContent.textContent &&
+ listContent.textContent.includes("Not Found")
+ ) {
+ return undefined;
+ }
- const chapterCount = html.querySelector('.epxs');
+ const chapterCount = html.querySelector(".epxs");
- if (chapterCount && chapterCount.textContent && chapterCount.textContent.includes('Chapter')) {
- return Number.parseInt(chapterCount.textContent.replace('Chapter', '').trim(), 10);
- }
+ if (
+ chapterCount &&
+ chapterCount.textContent &&
+ chapterCount.textContent.includes("Chapter")
+ ) {
+ return Number.parseInt(
+ chapterCount.textContent.replace("Chapter", "").trim(),
+ 10,
+ );
+ }
- return undefined;
+ return undefined;
};
export const getChaptersFromText = (text: string) => {
- const dom = new DOMParser().parseFromString(text, 'text/html').querySelectorAll('.eph-num');
- const chapters: Chapter[] = [];
-
- dom.forEach((chapter) => {
- const href = chapter.querySelector('a')?.getAttribute('href');
- const chapterNum = chapter.querySelector('.chapternum')?.textContent;
- const chapterDate = chapter.querySelector('.chapterdate')?.textContent;
-
- if (href && chapterNum && chapterDate)
- chapters.push({
- href,
- chapterNum,
- chapterDate
- });
- });
-
- return chapters;
+ const dom = new DOMParser()
+ .parseFromString(text, "text/html")
+ .querySelectorAll(".eph-num");
+ const chapters: Chapter[] = [];
+
+ dom.forEach((chapter) => {
+ const href = chapter.querySelector("a")?.getAttribute("href");
+ const chapterNum = chapter.querySelector(".chapternum")?.textContent;
+ const chapterDate = chapter.querySelector(".chapterdate")?.textContent;
+
+ if (href && chapterNum && chapterDate)
+ chapters.push({
+ href,
+ chapterNum,
+ chapterDate,
+ });
+ });
+
+ return chapters;
};