Greasy Fork

Greasy Fork is available in English.

pterclub自动认领

用户页自动认领所有种子

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         pterclub自动认领
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  用户页自动认领所有种子
// @author       albao
// @match        https://pterclub.com/getusertorrentlist.php*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...
    var button = document.createElement('button');
    button.id = 'auto-confirm';
    button.textContent = '认领';
    button.style.height = '20px';
    button.style.width = '60px';
    button.style.fontsize = '3px';
    button.onclick = function (){
        //var tbl = document.getElementById('ka1');
        //var l = tbl.getElementsByClassName('claim-confirm');
        var elements = document.querySelectorAll('.claim-confirm');
        var total = elements.length;
        var cnt = 0;
        var cnt_error = 0;
        var completedRequests = 0;

        function makeRequest(index) {
            if (index >= total) {
                return; // 停止递归
            }

            var element = elements[index];

            if (element.hasAttribute('data-url')) {
                var httpRequest = new XMLHttpRequest();
                var url = 'https://pterclub.com/' + element.getAttribute('data-url');

                httpRequest.onreadystatechange = function() {
                    if (this.readyState == 4) {
                        completedRequests++;
                        if (this.status == 200) {
                            if (this.response.includes('添加成功') || this.response.includes('\\u6dfb\\u52a0\\u6210\\u529f')) { // 假设实际字符串是 '添加成功'
                                cnt++;
                                console.log('认领成功');
                            } else {
                                cnt_error++;
                                console.log('认领失败');
                            }
                        } else {
                            console.error('请求失败:', this.status);
                        }
                        if (completedRequests === total) {
                            setTimeout(function() {
                                alert('认领成功:' + cnt + '\n认领失败:' + cnt_error);
                            }, 100); // 延迟警告以避免潜在的性能问题
                        }
                    }
                };

                httpRequest.open('GET', url, true);
                httpRequest.send();
            } else {
                completedRequests++;
            }

            setTimeout(function() {
                makeRequest(index + 1); // 递归调用并增加延迟
            }, 100);
        }

        makeRequest(0); // 开始第一个请求

    }
    var x = document.getElementById('outer').getElementsByTagName('h1')[0].getElementsByTagName('span')[0];
    x.append(button);
})();