百度网盘直接下载助手 生成链接到 Aria2 WebUI, 包含--out filename

try to take over the world!

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         百度网盘直接下载助手 生成链接到 Aria2 WebUI, 包含--out filename
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @require      https://code.jquery.com/jquery-latest.js
// @match        *://pan.baidu.com/disk/home*
// @match        *://yun.baidu.com/disk/home*
// @match        *://pan.baidu.com/s/*
// @match        *://yun.baidu.com/s/*
// @match        *://pan.baidu.com/share/link*
// @match        *://yun.baidu.com/share/link*
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';

    $(document.body).on('click', '.g-dropdown-button', function() {
        let id = 'dialog-copy-button-with-out';
        for (let i=0; i < 5; ++i) {
            setTimeout(() => {
                if (! document.getElementById(id)) {
                    $('.dialog').each(function() {
                        let $this = $(this);
                        if ($this.find('.dialog-header h3').text() === '批量链接') {
                            var $button = $this.find('.dialog-button > div').append(`<button id="${id}">复制为url --out filename</button>`);
                            $button.on('click', function() {
                                copyUrls($this);
                            });
                        }
                    });
                }
            }, 200 * i);
        }
    });

    function copyUrls($this) {
        let urls = [];
        $this.find('.dialog-body > div').each(function() {
            urls.push(`${$(this).find('a').attr('href')} --out=${$(this).find('div').text()}`);
        });
        urls = urls.join('\n');
        GM_setClipboard(urls, 'text');
        alert('已将链接复制到剪贴板!');
    }
})();