Update anime-sama/anime-sama.js

This commit is contained in:
aka paul 2026-01-06 20:27:33 +00:00
parent cafc9dea38
commit 6ec67bcfb8

View file

@ -1,16 +1,38 @@
async function getActiveDomain() {
try {
const response = await fetchv2("https://anime-sama.pw/");
const html = await response.text();
const domainRegex = /<td class="domain-name">([^<]+)<\/td>[\s\S]*?<p class="hidden md:block">Actif<\/p>/;
const match = domainRegex.exec(html);
if (match) {
return match[1].trim();
} else {
return "anime-sama.tv";
}
} catch (err) {
console.error("Failed to fetch active domain:", err);
// Fallback
return "anime-sama.tv";
}
}
async function searchResults(keyword) { async function searchResults(keyword) {
const results = []; const results = [];
const activeDomain = await getActiveDomain();
const headers = { const headers = {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With": "XMLHttpRequest", "X-Requested-With": "XMLHttpRequest",
"referer": "https://anime-sama.org/" "referer": `https://${activeDomain}/`
}; };
const regex = /<a[^>]+href="([^"]+)"[\s\S]*?<img[^>]+src="([^"]+)"[\s\S]*?<h3[^>]*>(.*?)<\/h3>/gi; const regex = /<a[^>]+href="([^"]+)"[\s\S]*?<img[^>]+src="([^"]+)"[\s\S]*?<h3[^>]*>(.*?)<\/h3>/gi;
try { try {
const response = await fetchv2( const response = await fetchv2(
"https://anime-sama.eu/template-php/defaut/fetch.php", `https://${activeDomain}/template-php/defaut/fetch.php`,
headers, headers,
"POST", "POST",
`query=${encodeURIComponent(keyword)}` `query=${encodeURIComponent(keyword)}`