Last active
November 10, 2023 18:39
-
-
Save notmarek/6eef0ac456e8698bc4f4e058adf67382 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name New script - animebytes.tv | |
// @namespace Violentmonkey Scripts | |
// @match https://animebytes.tv/torrents.php* | |
// @grant none | |
// @version 1.1 | |
// @author - | |
// @description 11/10/2023, 4:38:44 PM | |
// ==/UserScript== | |
(async()=>{ | |
async function getFromAPI(page = 1) { | |
let group_id = document.querySelector(`input[name="thread"]`).value; | |
let torrent_key = document.querySelector("head > link[href*='rss_torrents_all']").href.split("/") | |
torrent_key = torrent_key[torrent_key.length - 1] | |
let username = document.querySelector("a.username").innerText | |
let api_url = `https://animebytes.tv/scrape.php?torrent_pass=${torrent_key}&username=${username}&hentai=0&type=anime&tags=abg-${group_id}&page=${page}` | |
let group = (await (await fetch(api_url)).json()).Groups.find(e => e.ID == Number(group_id)) | |
// cope harder lol | |
if (!group) { | |
return getFromAPI(page + 1) | |
} | |
return group | |
} | |
function copyFilelist(tid) { | |
let torrent = data.Torrents.find(e => e.ID == tid); | |
let finalstring = "" | |
for (let file of torrent.FileList) { | |
finalstring += `${file.filename}\t${file.size}\n` | |
} | |
navigator.clipboard.writeText(finalstring) | |
console.log(finalstring) | |
} | |
function spawnButtons() { | |
document.querySelectorAll(`ul[id*="tabs_"]`).forEach(e => { | |
let tid = e.id.split("_")[1] | |
let child = document.createElement("li") | |
let btn = document.createElement("a") | |
btn.innerText = "Copy Filelist" | |
btn.href = "#" | |
btn.onclick = () => { copyFilelist(Number(tid)) } | |
child.appendChild(btn) | |
e.appendChild(child) | |
}) | |
} | |
let data = await getFromAPI() | |
spawnButtons() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment