Xunlei KuaiChuan Export Links

在新标签页显示迅雷快传中已勾选链接文本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Xunlei KuaiChuan Export Links
// @namespace   qixinglu.com
// @description 在新标签页显示迅雷快传中已勾选链接文本
// @grant       none
// @include     http://kuai.xunlei.com/d/*
// @version 0.2
// modified by Kun Wang <ifreedom.cn AT gmail.com>
// ==/UserScript==

var addStyle = function(cssText) {
    var head = document.querySelector('head');
    var style = document.createElement('style');
    style.setAttribute('type', 'text/css');
    style.textContent = cssText;
    head.appendChild(style);
};

var replaceButton = function() {
    // 复制按钮,避免处理点击事件而弹出下载迅雷提示
    var orignalButton = document.querySelector('.general_btn');
    var newButton = orignalButton.cloneNode(true);

    newButton.addEventListener('click', function() {
        var rows = document.querySelectorAll('.file_src li');
        var i, row;
        var links = [];
        for (i = 0; i < rows.length; i += 1) {
            row = rows[i];
            if (row.querySelector('input.file_chk').checked) {
                links.push(row.querySelector('a.file_name').href);
            }
        }
        var text = 'data:text/plain,' + encodeURIComponent(links.join('\n'));
        window.open(text);
    });

    orignalButton.parentNode.replaceChild(newButton, orignalButton);
};

// 需要用到这个脚本都不需要显示「高速下载」按钮,隐藏掉。
var fileCSS = 'a.high_btn, .adb_txt { display: none; }';

// 干掉「离线下载」按钮的菜单
document.querySelector('.operation').remove();

addStyle(fileCSS);
replaceButton();