Update anihq/anihq.js

This commit is contained in:
aka paul 2025-12-17 21:01:52 +00:00
parent 86df6eac73
commit 0008aeeede

View file

@ -1,21 +1,57 @@
async function searchResults(keyword) {
const results = [];
const headers = {
"Content-Type": "multipart/form-data; boundary=----geckoformboundary38c356867533a17de80e8c65d9125df5"
};
const postData = `------geckoformboundary38c356867533a17de80e8c65d9125df5
Content-Disposition: form-data; name="s_keyword"
${keyword}
------geckoformboundary38c356867533a17de80e8c65d9125df5
Content-Disposition: form-data; name="orderby"
popular
------geckoformboundary38c356867533a17de80e8c65d9125df5
Content-Disposition: form-data; name="order"
DESC
------geckoformboundary38c356867533a17de80e8c65d9125df5
Content-Disposition: form-data; name="action"
advanced_search
------geckoformboundary38c356867533a17de80e8c65d9125df5
Content-Disposition: form-data; name="page"
1
------geckoformboundary38c356867533a17de80e8c65d9125df5--`;
try {
const response = await fetchv2("https://anihq.to/search/?s_keyword=" + encodeURIComponent(keyword));
const html = await response.text();
const response = await fetchv2("https://anihq.org/wp-admin/admin-ajax.php", headers, "POST", postData);
const data = await response.json();
const html = data.data.html;
const articlePattern = /<article[^>]*class="anime-card[^"]*"[^>]*>([\s\S]*?)<\/article>/g;
let articleMatch;
const regex = /<div class="w-full bg-gradient-to-t from-primary to-transparent[^"]*"[\s\S]*?<img src=['"]([^'"]+)['"][^>]*alt=['"]([^'"]+)['"][\s\S]*?<a[^>]+href=['"]([^'"]+)['"][\s\S]*?<\/div>\s*<\/div>/g;
let match;
while ((match = regex.exec(html)) !== null) {
results.push({
title: match[2].trim(),
image: match[1].trim(),
href: match[3].trim()
});
while ((articleMatch = articlePattern.exec(html)) !== null) {
const articleHtml = articleMatch[1];
const imgMatch = articleHtml.match(/<img[^>]+src=['"]([^'"]+)['"][^>]+alt=['"]([^'"]+)['"]/);
const linkMatch = articleHtml.match(/<h3[^>]*>[\s\S]*?<a[^>]+href=['"]([^'"]+)['"][^>]*title=['"]([^'"]+)['"]/);
if (imgMatch && linkMatch) {
results.push({
title: linkMatch[2].trim(),
image: imgMatch[1].trim(),
href: linkMatch[1].trim()
});
}
}
return JSON.stringify(results);
} catch (err) {
console.log(err);
return JSON.stringify([{
title: "Error",
image: "Error",
@ -24,6 +60,7 @@ async function searchResults(keyword) {
}
}
async function extractDetails(url) {
try {
const response = await fetchv2(url);
@ -105,7 +142,7 @@ async function extractStreamUrl(url) {
const response = await fetchv2(url);
const html = await response.text();
const iframeMatch = html.match(/(?:data-lazy-src|src)=["']https:\/\/(anihqq?\.strp2p\.com)\/#([^"']+)["']/);
const iframeMatch = html.match(/<iframe[^>]+src=['"]https:\/\/([^'"]+\.playerp2p\.com)\/#([^'"]+)['"]/);
if (!iframeMatch) {
console.log("No iframe ID found");