Xunlei Kuaichuan Display Full Filename

迅雷快传上的下载链接显完整文件名

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Xunlei Kuaichuan Display Full Filename
// @namespace   qixinglu.com
// @description 迅雷快传上的下载链接显完整文件名
// @grant       none
// @include     http://kuai.xunlei.com/d/*
// @include     http://kuai.xunlei.com/s/*
// @version 0.0.1.20140517140354
// ==/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 fullName = function() {
    // 从 title 标签复制完整文件名
    var nodes = document.querySelectorAll('.c_2 a.file_name');
    var i, node;
    for (i = 0; i < nodes.length; i += 1) {
        node = nodes[i];
        node.textContent = node.title;
    }
};

var swapSizePriviewInfo = function() {
    // 交换「文件大小」和「云预览」信息位置
    var nodes = document.querySelectorAll('.c4');
    var i, node;
    for (i = 0; i < nodes.length; i += 1) {
        node = nodes[i];
        if (node.classList.length === 1) {
            node.parentNode.appendChild(node);
        }
    }
};

var filesCSS =
    '.adv_area, .file_right, .advl, .hot_list {' +
    '    display: none !important;' +
    '}' +
    '.file_left, .file_src, .file_src li {' +
    '    width: 100% !important;' +
    '    height: 100% !important;' +
    '}' +
    '.c_2, .c_2 a{' +
    '    width: auto !important;' +
    '}' +
    '.c4.status {' +
    '    width: 100px !important;' +
    '}' +
    '.c4 {' +
    '    float: right !important;' +
    '}';

var folderCSS =
    '.file_left, .downLoad_area {' +
    '    width: 100% !important;' +
    '}' +
    '.file_w, .file_list {' +
    '    height: 100% !important;' +
    '}';

if (location.href.indexOf('http://kuai.xunlei.com/s/') === 0) {
    addStyle(folderCSS);
} else {
    addStyle(filesCSS);
    fullName();
    swapSizePriviewInfo();
}