// ==UserScript== // @name 烧包一键认领 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 一键认领烧包已保种 // @author ootruieo // @match https://ptsbao.club/userdetails.php?id=* // @grant unsafeWindow // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Your code here... function sleep(time) { return new Promise((resolve) => setTimeout(resolve, time)).catch((e)=>{console.log(e);}); } window.onload = function(){ var rows = document.querySelectorAll("tr"); for (var i = 0; i < rows.length; i++) { if(rows[i].childElementCount==2 && rows[i].cells[0].innerText=="当前做种"){ var idClaim = document.getElementById("claimAllTorrents"); if(idClaim == null){ rows[i].cells[1].innerHTML+=('一键认领'); break; } } } } unsafeWindow.manualClaimTorrents = async function(){ var msg = "确定要认领全部种子吗?\n\n严正警告:\n请勿短时间内多次点击,否则后果自负!\n请勿短时间内多次点击,否则后果自负!\n请勿短时间内多次点击,否则后果自负!"; if (confirm(msg)==true){ var x = document.querySelectorAll("a"); for (var i = 0; i < x.length; i++) { if(x[i].href.indexOf("getusertorrentlistajax") != -1 && x[i].href.indexOf("seeding") != -1) { eval(x[i].href); var seeding = document.getElementById("ka1"); var seedingNodes = seeding.childNodes; var retryCount = 0; while(retryCount<5 && seedingNodes.length ==0){ await sleep(1000); retryCount += 1; seedingNodes = seeding.childNodes; } var total = 0, success = 0; for(var ti=1;ti= 500) { alert("最多只能认领500个种子!"); break; } var titleElementA = seedingNodes[3].rows[ti].cells[1].getElementsByTagName('a')[0]; var torrentid = titleElementA.href.replace("https://ptsbao.club/","").replace("details.php?id=","").replace("&hit=1",""); var result = ajax.gets('claim.php?torrentid=' + torrentid); total += 1; if (result != "claim") { seedingNodes[3].rows[ti].setAttribute("style", "background:LightPink !important"); } else { seedingNodes[3].rows[ti].setAttribute("style", "background:LightGreen !important"); success += 1; } await sleep(50); } alert(`共计${total}个种子,本次成功认领${success}个。`); var idClaim = document.getElementById("claimAllTorrents"); idClaim.parentNode.removeChild(idClaim); } } } } })();