DICMusic Unchecked

Open unchecked torrents

当前为 2025-02-05 提交的版本,查看 最新版本

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         DICMusic Unchecked
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Open unchecked torrents
// @match        https://dicmusic.com/torrents.php
// @match        https://dicmusic.com/torrents.php?page=*
// @grant        none
// @license MIT
// ==/UserScript==

// 用户配置 - 设置一次性打开的最大链接数量 (0 表示不限制)
const MAX_LINKS = 20;

(function() {
    'use strict';

    // Wait for DOM to be ready
    function init() {
        // Find the statistics panel container
        const statsPanel = document.querySelector('.alertbar.blend');
        if (!statsPanel) return;

        // Create a button to trigger link opening
        const button = document.createElement('a');
        button.textContent = 'Open Unchecked';
        button.href = 'javascript:void(0);';
        button.style.marginLeft = '10px'; // Add some spacing between links

        // Insert the button after the statistics link
        statsPanel.appendChild(button);

        button.addEventListener('click', function() {
            // Find all groups that match our criteria
            const groups = document.querySelectorAll('tr.group');
            // Store all album links
            const albumLinks = [];

            groups.forEach(group => {
                // Skip if the group has the torrent_all_checked class
                if (group.classList.contains('torrent_all_checked')) {
                    return;
                }
                // Find the album link within each group
                const albumLink = group.querySelector('a[href^="torrents.php?id="]');
                if (albumLink) {
                    const href = albumLink.getAttribute('href');
                    // Create full URL by combining with base URL
                    const fullUrl = 'https://dicmusic.com/' + href;
                    albumLinks.push(fullUrl);
                }
            });

            // Apply limit if MAX_LINKS is greater than 0
            const linksToOpen = MAX_LINKS > 0 ? albumLinks.slice(0, MAX_LINKS) : albumLinks;

            // Show warning if links were limited
            if (MAX_LINKS > 0 && albumLinks.length > MAX_LINKS) {
                alert(`已设置最大打开链接数为 ${MAX_LINKS} \n找到 ${albumLinks.length} 个链接,将只打开前 ${MAX_LINKS} 个 \n处理完成后请刷新本页面`);
            }

            // Open each link
            linksToOpen.forEach(url => {
                window.open(url, '_blank');
            });
        });
    }

    // Run initialization when DOM is ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init);
    } else {
        init();
    }
})();