From 68f09146a183d6bd3670112879fa9372d6ac3828 Mon Sep 17 00:00:00 2001 From: aka paul <50n50@noreply.localhost> Date: Sun, 30 Nov 2025 20:26:17 +0000 Subject: [PATCH] Add mangapub/mangapub.js --- mangapub/mangapub.js | 101 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 mangapub/mangapub.js diff --git a/mangapub/mangapub.js b/mangapub/mangapub.js new file mode 100644 index 0000000..1bfa496 --- /dev/null +++ b/mangapub/mangapub.js @@ -0,0 +1,101 @@ +async function searchContent(keyword, page=0) { + const results = []; + try { + const response = await fetch("https://mangapub.com/api/book/search?q=" + encodeURIComponent(keyword)); + const html = await response.text(); + + const regex = /]*href="([^"]*)"[^>]*>[\s\S]*?]*src="([^"]*)"[\s\S]*?]*>[\s\S]*?]*>([\s\S]*?)<\/a>[\s\S]*?<\/h3>/g; + + let match; + while ((match = regex.exec(html)) !== null) { + results.push({ + id: "https://mangapub.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 [^\s<]+)<\/strong>/g; + + let match; + + while ((match = regex.exec(chapHtml)) !== null) { + const chapterUrl = "https://mangapub.com" + match[1]; + const chapterTitle = match[2]; + const chapterNum = chapterTitle.replace('Chapter ', ''); + results.push([ + chapterNum, + [{ + id: chapterUrl, + title: chapterTitle, + chapter: parseFloat(chapterNum), + scanlation_group: chapterTitle + }] + ]); + } + + 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 = /indicators = "([^"]*)"/; + const match = regex.exec(html); + if (match) { + const images = match[1].split(','); + const processedImages = images.map(img => img.trim()).filter(img => img.length > 0); + results.push(...processedImages); + } + + return results; + } catch (err) { + return []; + } +} \ No newline at end of file