Greasy Fork

Greasy Fork is available in English.

Torrent Kitty Content Size Get

Get real size of the torrents with out page jumps.

当前为 2020-08-02 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Torrent Kitty Content Size Get
// @namespace    https://boblee.cn
// @version      0.5
// @description  Get real size of the torrents with out page jumps.
// @author       Bob Lee
// @match        *://www.torrentkitty.tv/search/*
// @grant        none
// ==/UserScript==


(function() {
    'use strict';

    window.getRealSize = function (parsedSize, parsedFormat) {
        if (parsedFormat == "KB") {
            parsedSize *= 1024;
        } else if (parsedFormat == "MB") {
            parsedSize *= 1024 * 1024;
        } else if (parsedFormat == "GB") {
            parsedSize *= 1024 * 1024 * 1024;
        } else if (parsedFormat == "TB") {
            parsedSize *= 1024 * 1024 * 1024 * 1024;
        } else {
            return -1;
        }
        return parsedSize;
    }

    window.topThisId = function (bob_tr_id) {
        var tr = document.getElementById(bob_tr_id);
        $(tr).fadeOut().fadeIn();
        $(tr).insertAfter($(tableHeader));
    }

    window.getSize = function (id, url) {
        $.ajax({
            url: "https://www.torrentkitty.tv" + url,
            type: "GET",
            beforeSend: function () {
                var target = document.getElementById('bob_td_' + id);
                target.innerText = "loading...";
            },
            success: function(res){
                var td_id = 'bob_td_' + id;
                var target = document.getElementById(td_id);
                var rawSize = ($(res).filter('div#main').children().filter('div.wrapper').children().filter('table.detailSummary').children().children().children()[7].innerText);
                var parsedSize = rawSize.split(' ')[0];
                var parsedFormat = rawSize.split(' ')[1];
                var realSize = getRealSize(parsedSize, parsedFormat);
                target.innerText = rawSize;
                if (realSize > maxSize) {
                    maxSize = realSize;
                    topThisId('bob_tr_' + id);
                }
            }
        })
    }

    window.getSizeAll = function () {
        for (var i = 1; i < table.length; i++) {
            window.getSize(i, urlList[i]);
        }
    }

    var maxSize = 0;
    var urlList = new Array();
    var table = $("table#archiveResult").children().children();
    var tableHeader = table[0];

    table[0].cells[1].innerHTML = '<th class="size"><a onclick=\'window.getSizeAll()\'>Content Size</a></th>';
    for (var i = 1; i < table.length; i++) {
        table[i].id = 'bob_tr_' + i;
        var tmpUrl = table[i].cells[3].innerHTML.split('"')[1];
        urlList[i] = tmpUrl;
        table[i].cells[1].innerHTML = "<a id='bob_td_" + i + "' onclick='window.getSize(\"" + i + '", "' + tmpUrl + "\")'>Get</a>";
    }

})();