auto open link from the list

auto open link from the list for carpt

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         auto open link from the list
// @namespace    https://carpt.net/
// @version      2024-01-31
// @description  auto open link from the list for carpt
// @author       Cccor
// @match        https://carpt.net/torrents.php*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=carpt.net
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    window.onbeforeunload = function() {
    return "确定要离开当前页面吗?";
};

    // 创建并添加按钮
    const createButton = (start, end) => {
        const button = document.createElement('button');
        button.textContent = `${start + 1}~${end}`;
        button.addEventListener('click', () => openPageRange(start, end));
        return button;
    };

    // 在页面上添加所有的按钮
    const addButtonToPage = () => {
        const searchButton = document.querySelector('input[value="给我搜"]');
        const container = searchButton.closest('td');

        for (let i = 0; i < 10; i++) {
            const start = i * 10;
            const end = (i + 1) * 10 - 1;
            const button = createButton(start, end);
            container.appendChild(button);
        }
    };

    // 打开指定范围内的链接
    const openPageRange = (start, end) => {
        const tables = document.querySelectorAll('table.torrentname');
        const downloadImgs = Array.from(tables).slice(start, end + 1).flatMap(table =>
            Array.from(table.querySelectorAll('img[title="下载本种"]'))
        );

        downloadImgs.forEach(img => {
            const downloadLink = img.closest('a');
            if (downloadLink && downloadLink.href) {
                window.open(downloadLink.href, '_blank');
            }
        });
    };

    addButtonToPage();
})();

QingJ © 2025

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