Greasy Fork is available in English.
Get real size of the torrents with out page jumps.
当前为
// ==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>";
}
})();