Open unchecked torrents
当前为
// ==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();
}
})();