Update mangafire/mangafire.js
This commit is contained in:
+11
-12
@@ -1,4 +1,4 @@
|
||||
async function searchResults(input,page=0){
|
||||
async function searchResults(input, page = 0) {
|
||||
function parseSearchResults(html) {
|
||||
const results = [];
|
||||
const regex = /<div class="unit item-\d+">[\s\S]*?<a href="\/manga\/([\w\-\.]+)"[^>]*class="poster"[\s\S]*?<img src="([^"]*)"[^>]*alt="([^"]*)"/g;
|
||||
@@ -13,7 +13,9 @@ async function searchResults(input,page=0){
|
||||
}
|
||||
|
||||
return results;
|
||||
} const vrf = generate_vrf(input);
|
||||
}
|
||||
|
||||
const vrf = generate_vrf(input);
|
||||
const response = await fetch("https://mangafire.to/filter?keyword=" + encodeURIComponent(input) + "&vrf=" + vrf);
|
||||
const data = await response.text();
|
||||
console.log(JSON.stringify(parseSearchResults(data)));
|
||||
@@ -32,15 +34,13 @@ async function extractDetails(url) {
|
||||
|
||||
const uniqueTags = [...new Set(tags)];
|
||||
|
||||
const ogDescriptionRegex =
|
||||
/<meta property="og:description" content=['"]([^'"]*)['"]/i;
|
||||
const ogDescriptionRegex = /<meta property="og:description" content=['"]([^'"]*)['"]/i;
|
||||
const ogMatch = htmlContent.match(ogDescriptionRegex);
|
||||
|
||||
let description = ogMatch ? ogMatch[1] : "";
|
||||
|
||||
if (!description) {
|
||||
const metaDescriptionRegex =
|
||||
/<meta name="description" content=['"]([^'"]*)['"]/i;
|
||||
const metaDescriptionRegex = /<meta name="description" content=['"]([^'"]*)['"]/i;
|
||||
const metaMatch = htmlContent.match(metaDescriptionRegex);
|
||||
description = metaMatch ? metaMatch[1] : "";
|
||||
}
|
||||
@@ -73,17 +73,17 @@ async function extractChapters(url) {
|
||||
const mangaIdMatch = url.match(/\.([a-z0-9]+)$/);
|
||||
const mangaId = mangaIdMatch ? mangaIdMatch[1] : null;
|
||||
|
||||
vrf = generate_vrf(`${mangaId}@chapter@en`);
|
||||
if (!mangaId) {
|
||||
console.error("Could not extract manga ID from URL");
|
||||
return null;
|
||||
}
|
||||
|
||||
const vrf = generate_vrf(`${mangaId}@chapter@en`);
|
||||
|
||||
function parseChapters(htmlContent) {
|
||||
const chapters = {};
|
||||
|
||||
const chapterRegex =
|
||||
/<a href="\/read\/[^"]+\/([^/]+)\/chapter-[^"]*" data-number="([^"]+)" data-id="([^"]+)"[^>]*>(.*?)<\/a>/gs;
|
||||
const chapterRegex = /<a href="\/read\/[^"]+\/([^/]+)\/chapter-[^"]*" data-number="([^"]+)" data-id="([^"]+)"[^>]*>(.*?)<\/a>/gs;
|
||||
|
||||
let match;
|
||||
while ((match = chapterRegex.exec(htmlContent)) !== null) {
|
||||
@@ -131,7 +131,7 @@ async function extractChapters(url) {
|
||||
}
|
||||
|
||||
async function extractImages(ID) {
|
||||
vrf = generate_vrf(`chapter@${ID}`);
|
||||
const vrf = generate_vrf(`chapter@${ID}`);
|
||||
|
||||
try {
|
||||
const response = await fetch(`https://mangafire.to/ajax/read/chapter/${ID}?vrf=${vrf}`);
|
||||
@@ -145,9 +145,8 @@ async function extractImages(ID) {
|
||||
console.error("Invalid response from server");
|
||||
return null;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error fetching chapters:" + error);
|
||||
console.error("Error fetching images:" + error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user