From 934a52eab81613dadff0b0642d6c2e8e11c6aa01 Mon Sep 17 00:00:00 2001 From: aka paul <50n50@noreply.localhost> Date: Sun, 30 Nov 2025 18:57:55 +0000 Subject: [PATCH] Add mangabuddy/mangabuddy.js --- mangabuddy/mangabuddy.js | 100 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 mangabuddy/mangabuddy.js diff --git a/mangabuddy/mangabuddy.js b/mangabuddy/mangabuddy.js new file mode 100644 index 0000000..fb72de6 --- /dev/null +++ b/mangabuddy/mangabuddy.js @@ -0,0 +1,100 @@ +async function searchContent(keyword, page=0) { + const results = []; + try { + const response = await fetch("https://mangabuddy.com/api/manga/search?q=" + encodeURIComponent(keyword)); + const html = await response.text(); + + const regex = /href="([^"]*)"[^>]*>[\s\S]*?]*>([\s\S]*?)<\/a><\/h3>/g; + + let match; + while ((match = regex.exec(html)) !== null) { + results.push({ + id: "https://mangabuddy.com" + match[1].trim(), + imageURL: match[2].trim(), + title: match[3].replace(/<[^>]+>/g, '').trim() + }); + } + + return results; + } catch (err) { + return []; + } +} + +async function getContentData(url) { + try { + const response = await fetch(url); + const html = await response.text(); + + const descRegex = /\s*]*>\s*
\s*Chapter (\d+)<\/strong>/g; + + let match; + + while ((match = regex.exec(chapHtml)) !== null) { + const chapterUrl = "https://mangabuddy.com" + match[1]; + const chapterNum = match[2]; + results.push([ + String(chapterNum), + [{ + id: chapterUrl, + chapter: parseInt(chapterNum), + scanlation_group: `Chapter ${chapterNum}` + }] + ]); + } + + results.reverse(); + + return { en: results }; + } catch (err) { + return { en: [] }; + } +} + +async function getChapterImages(url) { + const results = []; + try { + const response = await fetch(url); + const html = await response.text(); + const regex = /var chapImages = '([^']*)'/; + const match = regex.exec(html); + if (match) { + const imagesString = match[1]; + const images = imagesString.split(','); + results.push(...images); + } + + return results; + } catch (err) { + return []; + } +} \ No newline at end of file