Greasy Fork

Greasy Fork is available in English.

Beyond-HD 种子批量下载器

下载 Beyond-HD 当前页面的所有种子

当前为 2024-12-20 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Beyond-HD 种子批量下载器
// @namespace    http://greasyfork.icu/zh-CN/users/1413398-babalala
// @version      1.0
// @description  下载 Beyond-HD 当前页面的所有种子
// @author       BABAlala
// @match        https://beyond-hd.me/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let downloadInterval = null;
    let dlButtons = [];
    let currentIndex = 0;

    // 创建“下载当前页面所有种子”按钮
    const startButton = document.createElement('button');
    startButton.textContent = '下载当前页面所有种子';
    startButton.style.position = 'fixed';
    startButton.style.top = '10px';
    startButton.style.right = '10px';
    startButton.style.zIndex = '9999';
    document.body.appendChild(startButton);

    // 创建“立即停止”按钮
    const stopButton = document.createElement('button');
    stopButton.textContent = '立即停止';
    stopButton.style.position = 'fixed';
    stopButton.style.top = '40px'; // 放在开始按钮下方
    stopButton.style.right = '10px';
    stopButton.style.zIndex = '9999';
    stopButton.disabled = true; // 初始禁用停止按钮
    document.body.appendChild(stopButton);

    // 查找符合条件的 DL 按钮
    function findDLButtons() {
        const allLinks = document.querySelectorAll('a');
        dlButtons = [];
        currentIndex = 0;

        allLinks.forEach(link => {
            // 使用 title 属性和 href 属性的开头部分进行判断
            if (link.title === "Download Torrent" && link.href.startsWith("https://beyond-hd.me/download/")) {
                dlButtons.push(link);
            }
        });

        console.log("找到符合条件的 DL 按钮数量:", dlButtons.length);
    }

    // 下载种子的函数
    function downloadTorrents() {
        if (currentIndex < dlButtons.length) {
            const dlButton = dlButtons[currentIndex];
            console.log("正在下载第", currentIndex + 1, "个种子,链接:", dlButton.href);
            dlButton.click();
            currentIndex++;
        } else {
            clearInterval(downloadInterval);
            downloadInterval = null;
            startButton.disabled = false;
            stopButton.disabled = true;
            alert('当前页面所有种子下载完成!');
        }
    }

    // 开始按钮的点击事件
    startButton.addEventListener('click', () => {
        findDLButtons();
        if (dlButtons.length > 0) {
            startButton.disabled = true;
            stopButton.disabled = false;
            downloadInterval = setInterval(downloadTorrents, 3000);
        } else {
            alert('没有找到符合条件的 DL 按钮!');
        }
    });

    // 停止按钮的点击事件
    stopButton.addEventListener('click', () => {
        clearInterval(downloadInterval);
        downloadInterval = null;
        startButton.disabled = false;
        stopButton.disabled = true;
        console.log("下载已停止");
        alert('下载已停止!');
    });
})();