async function searchResults(keyword) { const results = []; try { const response = await fetchv2("https://anihq.to/search/?s_keyword=" + encodeURIComponent(keyword)); const html = await response.text(); const regex = /
]*alt=['"]([^'"]+)['"][\s\S]*?]+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() }); } return JSON.stringify(results); } catch (err) { return JSON.stringify([{ title: "Error", image: "Error", href: "Error" }]); } } async function extractDetails(url) { try { const response = await fetchv2(url); const html = await response.text(); const descMatch = html.match(/]*>([\s\S]*?)<\/div>/); let description = "N/A"; if (descMatch) { description = descMatch[1] .trim() .replace(/<[^>]+>/g, '') .replace(/\s+/g, ' ') .trim(); } return JSON.stringify([{ description: description, aliases: "N/A", airdate: "N/A" }]); } catch (err) { return JSON.stringify([{ description: "Error", aliases: "Error", airdate: "Error" }]); } } async function extractEpisodes(url) { const results = []; try { const response = await fetchv2(url); const html = await response.text(); const watchUrlMatch = html.match(/]*class="[^"]*episode-list-item[^"]*"[^>]*data-episode-search-query="(\d+)"[\s\S]*?\s*(\d+)\s*<\/span>/g; let match; while ((match = episodeRegex.exec(watchHtml)) !== null) { results.push({ href: match[1].trim(), number: parseInt(match[2], 10) }); } if (results.length === 0) { return JSON.stringify([{ href: watchUrl, number: 1 }]); } return JSON.stringify(results); } catch (err) { return JSON.stringify([{ href: "Error: " + err.message, number: "Error" }]); } } async function extractStreamUrl(url) { try { const response = await fetchv2(url); const html = await response.text(); const iframeMatch = html.match(/(?:data-lazy-src|src)=["']https:\/\/(anihqq?\.strp2p\.com)\/#([^"']+)["']/); if (!iframeMatch) { console.log("No iframe ID found"); return "https://error.org/"; } const domain = iframeMatch[1]; const videoId = iframeMatch[2]; const apiUrl = `https://${domain}/api/v1/video?id=${videoId}&w=1792&h=1120&r=anihq.to`; const apiResponse = await fetchv2(apiUrl); const encodedString = await apiResponse.text(); const hasUppercase = /[A-Z]/.test(encodedString); let stringToSend; if (hasUppercase) { stringToSend = atob(encodedString); console.log("Decoded string: " + stringToSend); } else { stringToSend = encodedString; console.log("Using encoded string directly (no uppercase found)"); } const postData = { text: stringToSend }; const headers = { "Content-Type": "application/json" }; const response2 = await fetchv2("https://enc-dec.app/api/dec-vidstack", headers, "POST", postData); const data = await response2.json(); console.log(JSON.stringify(data)); console.log("Final URL: " + data.result.source); return data.result.cf; } catch (err) { console.log("Error: " + err.message); return "https://error.org/"; } }