熊猫一键认领

一键认领熊猫已保种

目前为 2025-04-09 提交的版本。查看 最新版本

// ==UserScript==
// @name         熊猫一键认领
// @namespace    https://pandapt.net/
// @version      0.1
// @description  一键认领熊猫已保种
// @author       Gu
// @match        https://pandapt.net/userdetails.php?id=*
// @grant        unsafeWindow
// ==/UserScript==
//v0.1 优先认领官种
 
(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+=('<a id="claimAllTorrents" href="javascript:void(0);" onclick="window.manualClaimTorrents();" style="margin-left:10px;font-weight:bold;color:red" title="认领全部当前做种(运行后无法停止,强制停止可关闭页面)">一键认领</a>');
                    break;
                }
            }
        }
    }
 
    unsafeWindow.manualClaimTorrents = async function(){
        var msg = "确定要认领全部种子吗?\n\n严正警告:\n请勿短时间内多次点击,否则后果自负!\n请勿短时间内多次点击,否则后果自负!\n请勿短时间内多次点击,否则后果自负!\nemmmm...没话说了!";
        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 seedingNodes = document.getElementById("ka1").childNodes;
                    var maxClaim = 500;
                    var result = await unsafeWindow.ClassificationClaimTorrents(seedingNodes[3], true, maxClaim);
                    var total = result.total;
                    var success = result.success;
                    if(success < maxClaim && total - success > 0){
                        result = await unsafeWindow.ClassificationClaimTorrents(seedingNodes[3], false, maxClaim - success);
                        success += result.success;
                    }
                    alert(`共计${total}个种子,本次成功认领${success}个。`);
                    var idClaim = document.getElementById("claimAllTorrents");
                    idClaim.parentNode.removeChild(idClaim);
                }
            }
        }
    }
 
    unsafeWindow.ClassificationClaimTorrents = async function(element, official, maxClaim)
    {
        var total = 0, success = 0;
        var reg = /[@-]\s?(FFansBD|OPS|FFansTV|FFansWEB|FFans)(|.mkv|.mp4)$/i ;
        for(var ti=1;ti<element.rows.length;ti++){
            if(success >= maxClaim) {
                alert("最多只能认领500个种子!");
                break;
            }
            var titleElementA = element.rows[ti].cells[1].getElementsByTagName('a')[0];
            total += 1;
            var matchOfficial = titleElementA.title.match(reg);
            if((matchOfficial == null && official) || (matchOfficial != null && !official)){
                continue;
            }
            var torrentid = titleElementA.href.replace("https://pandapt.net/","").replace("details.php?id=","").replace("&hit=1","");
            var result = ajax.gets('claim.php?torrentid=' + torrentid);
            if (result != "claim") {
                element.rows[ti].setAttribute("style", "background:LightPink !important");
            } else {
                element.rows[ti].setAttribute("style", "background:LightGreen !important");
                success += 1;
            }
            await sleep(50);
        }
        return{
            total:total,
            success:success
        }
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址