您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Allows batch download of all displayed results in one single click.
当前为
- // ==UserScript==
- // @name [nyaa.si] Batch Download
- // @description Allows batch download of all displayed results in one single click.
- // @author MetalTxus
- // @version 1.0.1
- // @include /^https?:\/\/\S*nyaa.si\S*/
- // @require http://code.jquery.com/jquery-3.2.1.min.js
- // @icon https://avatars3.githubusercontent.com/u/28658394?s=48
- // @namespace https://greasyfork.org/users/8682
- // ==/UserScript==
- (function() {
- 'use strict';
- var DEBUGGING_ENABLED = false,
- MAGNET_SELECTOR = 'a[href*="/download/"]',
- DOWNLOADS_SELECTOR = '.mt-hidden-downloads',
- DOWNLOAD_INTERVAL = 1000;
- var fileCount = 0;
- function appendBatchDownloadButton () {
- fileCount = $(MAGNET_SELECTOR).length;
- if (fileCount) {
- $('.torrent-list').append(
- '<tr style="background: none;">' +
- '<td colspan="9" align="center">' +
- '<a title="Download all" href="#" class="mt-batch-download">< Download all (' + fileCount + ') ><br>' +
- '<i class="fa fa-fw fa-magnet"></i>' +
- '</a>' +
- '</td>' +
- '</tr>');
- $('.mt-batch-download').click(downloadAll);
- $('body').append($('<div class="mt-hidden-downloads">').hide());
- }
- }
- function downloadAll(event) {
- event.preventDefault();
- $(DOWNLOADS_SELECTOR).html('');
- $(MAGNET_SELECTOR).each(function (i, downloadLink) {
- setTimeout(function () {
- var url = downloadLink.href;
- downloadSingle(url);
- if (DEBUGGING_ENABLED) {
- var label = $(downloadLink).parents('tr').find('a[href^="/view/"]').eq(0).text();
- console.debug('[nyaa.si] Batch Download: Downloading torrent ' + (i + 1) + '/' + fileCount + ' ("' + label + '", ' + url + ')');
- }
- }, i * DOWNLOAD_INTERVAL);
- });
- }
- function downloadSingle (url) {
- $(DOWNLOADS_SELECTOR).append($('<iframe>').attr('src', url));
- }
- function initialize () {
- appendBatchDownloadButton();
- }
- initialize();
- })();