From fa2c44fe4e94df33f0d571c4f8f619528ec7f443 Mon Sep 17 00:00:00 2001 From: aka paul <50n50@noreply.localhost> Date: Sat, 29 Nov 2025 19:45:32 +0000 Subject: [PATCH] Add mangapark/mangapark.js --- mangapark/mangapark.js | 139 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 mangapark/mangapark.js diff --git a/mangapark/mangapark.js b/mangapark/mangapark.js new file mode 100644 index 0000000..7838353 --- /dev/null +++ b/mangapark/mangapark.js @@ -0,0 +1,139 @@ +function decodeHtmlEntities(text) { + const map = { + ''': "'", + '"': '"', + '&': '&', + '<': '<', + '>': '>', + ''': "'", + '/': '/', + '`': '`', + '=': '=', + }; + return text.replace(/&#?\w+;/g, (entity) => map[entity] || entity); +} + +async function searchContent(keyword) { + const results = []; + + const pages = [0, 2, 3, 4, 5]; + + try { + const promises = pages.map(page => { + const url = page === 0 + ? `https://mangapark.net/search?word=${encodeURIComponent(keyword)}` + : `https://mangapark.net/search?word=${encodeURIComponent(keyword)}&page=${page}`; + + return fetch(url) + .then(response => response.text()) + .then(html => { + const regex = /]*>[\s\S]*?]*?title="([^"]+)"/g; + const pageResults = []; + + let match; + while ((match = regex.exec(html)) !== null) { + pageResults.push({ + id: "https://mangapark.net" + match[1].trim(), + imageURL: "https://mangapark.net" + match[2].trim(), + title: decodeHtmlEntities(match[3].trim()) + }); + } + + return pageResults; + }) + .catch(() => []); + }); + + const allResults = await Promise.all(promises); + + return allResults.flat(); + + } catch (err) { + return []; + } +} + +async function getContentData(url) { + try { + const response = await fetch(url); + const html = await response.text(); + + const descRegex = /
([\s\S]*?)<\/div>/; + const descMatch = html.match(descRegex); + let description = descMatch ? descMatch[1].trim() : ""; + description = description.replace(//g, '\n').replace(/<[^>]+>/g, ''); + + const tagsRegex = //g; + const tags = []; + let tagMatch; + while ((tagMatch = tagsRegex.exec(html)) !== null) { + tags.push(tagMatch[1].trim()); + } + + return { + description, + tags + }; + } catch (err) { + return { + description: "Error", + tags: [] + }; + } +} + +async function getChapters(url) { + const results = []; + try { + const response = await fetch(url); + const html = await response.text(); + const regex = /]*>Chapter (\d+(?:\.\d+)?)[^<]*<\/a>/g; + let match; + let index = 0; + while ((match = regex.exec(html)) !== null) { + results.push([ + String(index), + [{ + id: "https://mangapark.net" + match[1].trim(), + title: `Chapter ${match[2].trim()}`, + chapter: index, + scanlation_group: "MangaPark" + }] + ]); + index++; + } + return { en: results.reverse() }; + } catch (err) { + return { en: [] }; + } +} + +async function getChapterImages(url) { + const results = []; + try { + const response = await fetch(url); + const html = await response.text(); + + const jsonMatch = html.match(/