From f004a1ff3ad7b872888d72552db34a62685835ad Mon Sep 17 00:00:00 2001 From: aka paul <50n50@noreply.localhost> Date: Wed, 26 Nov 2025 18:24:38 +0000 Subject: [PATCH] Update mangafire/mangafire.js --- mangafire/mangafire.js | 98 ++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/mangafire/mangafire.js b/mangafire/mangafire.js index 8146ed9..1d6c56e 100644 --- a/mangafire/mangafire.js +++ b/mangafire/mangafire.js @@ -25,30 +25,44 @@ async function getContentData(url) { const genreRegex = /([^<]+)<\/a>/g; const tags = []; let match; - + while ((match = genreRegex.exec(htmlContent)) !== null) { - tags.push(match[1]); + if (match[1].trim()) tags.push(match[1].trim()); } - + const uniqueTags = [...new Set(tags)]; - - const ogDescriptionRegex = /') + .replace(/\s+/g, ' ') + .trim(); + + if (uniqueTags.length === 0) { + uniqueTags.push("Unknown"); + } + return { - tags: uniqueTags, - description: description + description: description, + tags: uniqueTags }; } + const response = await fetch(`https://mangafire.to${url}`); const data = await response.text(); console.log(JSON.stringify(parseHtmlData(data))); @@ -65,38 +79,38 @@ async function getChapters(url) { return null; } - function parseChapters(htmlContent) { + function parseChapters(htmlContent) { const chapters = {}; - - const chapterRegex = /]*>([^<]+)<\/a>/g; - + + const chapterRegex = + /]*>(.*?)<\/a>/gs; + let match; while ((match = chapterRegex.exec(htmlContent)) !== null) { - const langCode = match[1]; - const chapterNumber = match[2]; - const chapterId = match[3]; - const title = match[4].trim(); - - if (!chapters[langCode]) { - chapters[langCode] = []; - } - - chapters[langCode].push([ + const langCode = match[1]; + const chapterNumber = match[2]; + const chapterId = match[3]; + const title = match[4].replace(/<[^>]*>/g, '').trim(); + + if (!chapters[langCode]) chapters[langCode] = []; + + chapters[langCode].push([ chapterNumber, - { - id: chapterId, - scanlation_group: "Mangafire", - title: title - } - ]); + [ + { + id: chapterId, + title: title, + chapter: Number(chapterNumber), + scanlation_group: "Mangafire" + } + ] + ]); } - - Object.keys(chapters).forEach(lang => { - chapters[lang].reverse(); - }); - + + Object.keys(chapters).forEach(lang => chapters[lang].reverse()); + return chapters; - } + } try { const response = await fetch(`https://mangafire.to/ajax/read/${mangaId}/chapter/en?vrf=${vrf}`);