[nyaa.si] Batch Download

Allows batch download of all displayed results in one single click.

目前为 2017-05-26 提交的版本。查看 最新版本

// ==UserScript==
// @name         [nyaa.si] Batch Download
// @description  Allows batch download of all displayed results in one single click.
// @author       MetalTxus
// @version      1.0.0

// @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://gf.qytechs.cn/users/8682
// ==/UserScript==

(function() {
    'use strict';

    //var MAGNET_SELECTOR = 'a[href*="magnet:"]';
    var MAGNET_SELECTOR = 'a[href*="/download/"]';

    function appendBatchDownloadButton () {
        var downloadLinks = $(MAGNET_SELECTOR),
            fileCount = downloadLinks.length;

        if (fileCount) {
            $('.torrent-list').append(
                '<tr style="background: none;">' +
                    '<td colspan="8" 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>');

            $('body').append('<div class="mt-hidden-downloads" style="display: none;">');

            $('.mt-batch-download').click(downloadAll);
        }
    }

    function downloadAll(event) {
        event.preventDefault();

        var hiddenDownloads = $('.mt-hidden-downloads').html('');

        $(MAGNET_SELECTOR).each(function (i, downloadLink) {
            var downloadIframe = $('<iframe>');
            downloadIframe.attr('src', downloadLink.href);
            hiddenDownloads.append(downloadIframe);
        });
    }

    function initialize() {
        appendBatchDownloadButton();
    }

    initialize();


})();

QingJ © 2025

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