// ==UserScript== // @name 官种保种统计 // @namespace https://greasyfork.org/zh-CN/scripts/ // @version 0.5 // @description count the size of the seeding official torrents, support PTer, SKY, OB, CHD, Hares. // @author ccf2012 // @match https://hdsky.me/userdetails.php?id=* // @match https://ourbits.club/userdetails.php?id=* // @match https://chdbits.co/userdetails.php?id=* // @match https://club.hares.top/userdetails.php?id=* // @match https://pterclub.com/userdetails.php?id=* // @match https://pterclub.com/getusertorrentlist.php?userid=*&type=seeding // @icon https://ourbits.club//favicon.ico // @grant GM_addElement // @grant GM.xmlHttpRequest // @downloadURL none // ==/UserScript== var config = { "https://hdsky.me": { seedList: "table > tbody > tr > td:nth-child(2) > a", seedListSize: "table > tbody > tr > td:nth-child(6)", seedingSummary: "table > tbody > tr > td > table > tbody > tr:nth-child(16) > td.rowfollow", matchRegex: /[@-]\s?(HDS)/i, }, "https://pterclub.com": { seedList: "#outer > table > tbody > tr > td:nth-child(2) > a:nth-child(1)", seedListSize: "#outer > table > tbody > tr > td:nth-child(4)", seedingSummary: "#outer > h1", matchRegex: /[@-]\s?(PTer)/i, }, "https://ourbits.club": { seedList: "table > tbody > tr > td:nth-child(2) > a", seedListSize: "table > tbody > tr > td:nth-child(3)", seedingSummary: "table > tbody > tr > td > table > tbody > tr:nth-child(18) > td.rowfollow", matchRegex: /[@-]\s?(Our|iLoveTV|FLTTH|Ao|MGs|HosT|iLoveHD)/i, }, "https://chdbits.co": { seedList: "table > tbody > tr > td:nth-child(2) > a", seedListSize: "table > tbody > tr > td:nth-child(3)", seedingSummary: "table > tbody > tr > td > table > tbody > tr:nth-child(16) > td.rowfollow", matchRegex: /[@-]\s?(CHD|blucook|HQC|GBT|KAN)/i, }, "https://club.hares.top": { seedList: "table > tbody > tr > td:nth-child(2) > a", seedListSize: "table > tbody > tr > td:nth-child(3)", seedingSummary: "table > tbody > tr > td > table > tbody > tr:nth-child(18) > td.rowfollow", matchRegex: /[@-]\s?(Hares)/i, }, }; function formatBytes(bytes, decimals = 2) { if (bytes === 0) return "0 Bytes"; const k = 1024; const dm = decimals < 0 ? 0 : decimals; const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i]; } function getSeedList(seedHtml) { var seedList = seedHtml.querySelectorAll( config[window.location.origin].seedList ); var seedListSize = seedHtml.querySelectorAll( config[window.location.origin].seedListSize ); var summary = GM_addElement( document.querySelector(config[window.location.origin].seedingSummary), "span", {} ); var countOT = 0; var sizeOT = 0; var regex = /[+-]?\d+(\.\d+)?/g; for (var i = 0; i < seedList.length; i++) { var seedName = seedList[i].title; if (seedName.match(config[window.location.origin].matchRegex)) { seedList[i].parentNode.style = "background-color: lightgreen;"; var seedSizeStr = seedListSize[i + 1].innerText; var num = seedSizeStr.match(regex).map(function (v) { return parseFloat(v); }); var size = 0; if (seedSizeStr.indexOf("KB") > 0) { size = num * 1024; } else if (seedSizeStr.indexOf("MB") > 0) { size = num * 1024 * 1024; } else if (seedSizeStr.indexOf("GB") > 0) { size = num * 1024 * 1024 * 1024; } else if (seedSizeStr.indexOf("TB") > 0) { size = num * 1024 * 1024 * 1024 * 1024; } else { size = num; } countOT++; sizeOT += size; } } summary.innerHTML = "
官种数量 " + countOT + " 官种大小 " + formatBytes(sizeOT) + "