I think the issue is due to DDOS guard
When I open the extension in webview then DDOS Protection Screen appears.
Even after the website is working in webview the app does not updates the content.
Miru version
1.8.1
Other details
To address this I made few changes in the extension to bypass ddos, which it does in the webview but the content is not shown in miru
Extension information
Animepahe
Steps to reproduce
Miru version
1.8.1
Other details
To address this I made few changes in the extension to bypass ddos, which it does in the webview but the content is not shown in miru
`// ==MiruExtension== // @name Animepahe // @version v0.0.2 // @author appdevelpo // @lang en // @license MIT // @icon https://animepahe.ru/pikacon.ico // @package animepahe.ru // @type bangumi // @webSite https://animepahe.ru // @nsfw false // ==/MiruExtension==
export default class extends Extension { async search(kw) { const res = await this.makeRequest(
/api?m=search&q=${kw}
); return res.data.map((item) => ({ title: item.title, url: item.session.toString(), cover: item.poster, })); }async latest(page) { try { const res = await this.makeRequest(
/api?m=airing&page=${page}
); return res.data.map((item) => ({ title: item.anime_title, url: item.anime_session.toString(), cover: item.snapshot, })); } catch (e){ const bangumi = [{ title: "error", url: "/", cover: null }]; return bangumi; } }async detail(url) { if(url=="/"){ return { title: "Blocked", cover: null, desc: "Please use webview to enter the website then close the webview window.", } } const res = await this.makeRequest("", { headers: { "Miru-Url":(.+?)<\/div>/)[1];
const epRes = await this.makeRequest(- [X] I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
https://animepahe.ru/anime/${url}
, }, }); const title = res.match(/(.+?)<\/span>/)[1]; const cover = res.match(/<a href="(https:\/\/i.animepahe.ru\/posters.+?)"/)[1]; const desc = res.match(//api?m=release&id=${url}
) const reverse_data = epRes.data.reverse(); return { title: title, cover: cover, desc: desc, episodes: [ { title: "SubsPlease-360p", urls: reverse_data.map((item) => ({ name:Episode ${item.episode}
, url:${url}/${item.session};0
,//url;quality })), }, { title: "SubsPlease-720p", urls: reverse_data.map((item) => ({ name:Episode ${item.episode}
, url:${url}/${item.session};1
, })), }, { title: "SubsPlease-1080p", urls: reverse_data.map((item) => ({ name:Episode ${item.episode}
, url:${url}/${item.session};2
, })), }, ], }; }async watch(url) { const url_split = url.split(';'); const res = await this.makeRequest("", { headers: { "Miru-Url":
https://animepahe.ru/play/${url_split[0]}
, } }); const src = res.match(/data-src="(https:\/\/kwik.si.+?)"/g)[parseInt(url_split[1])].match(/data-src="(.+?)"/)[1]; const hid_res = await this.makeRequest("", { headers: { "Miru-Url": src, "Referer": "https://animepahe.com", "User-Agent": this.randomUserAgent() } }); const hid_script = hid_res.match(/eval(f.+?}))/g)[1]; const decode_script = eval(hid_script.match(/eval(.+)/)[1]); const decode_url = decode_script.match(/source='(.+?)'/)[1]; return { type: "hls", url: decode_url, }; }// Function to make requests with custom headers and delay async makeRequest(url, options = {}) { try { const defaultOptions = { headers: { "User-Agent": this.randomUserAgent(), "Accept-Language": "en-US,en;q=0.9" } }; const requestOptions = { ...defaultOptions, ...options }; const response = await axios.get(url, requestOptions); // delay between requests to avoid triggering DDOS protection await delay(2000); return response.data; } catch (error) { console.error('Error making request:', error); throw error; } }
// Function to generate a random user agent randomUserAgent() { const userAgents = [ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0", ]; return userAgents[Math.floor(Math.random() * userAgents.length)]; } } `
Acknowledgements
Working