您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Calculates setected torrents size and displays a total in the toolbar
当前为
// ==UserScript== // @name Calculate qBittorrent selected torrents size // @namespace http://tampermonkey.net/ // @version v0.2 // @description Calculates setected torrents size and displays a total in the toolbar // @author me // @match http://localhost:8080/ // @icon https://www.google.com/s2/favicons?sz=64&domain=undefined.localhost // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; var trElement = document.querySelector("#desktopFooter > table > tbody > tr") var selectedSizeTotalElement = document.createElement("td"); selectedSizeTotalElement.id = "selectedSizeTotal"; selectedSizeTotalElement.textContent = "Selected Torrents Total: 0.00"; var statusBarSeparatorElement = document.createElement("td"); statusBarSeparatorElement.className = "statusBarSeparator"; // Insert the new elements before the existing ones trElement.insertBefore(selectedSizeTotalElement, trElement.firstElementChild); trElement.insertBefore(statusBarSeparatorElement, trElement.firstElementChild.nextSibling); var previousSelectedRows = []; var totalSpanId = 'totalSpan'; function calculateTotal() { var kib = 0; var mib = 0; var gib = 0; var total = ""; var selectedRows = document.querySelectorAll("tr.torrentsTableContextMenuTarget.selected"); // Check if selectedRows array is bigger than 0 if (selectedRows.length > 0) { // Check if selectedRows has changed if (!arraysAreEqual(previousSelectedRows, selectedRows)) { selectedRows.forEach(function (row) { var tSize = row.childNodes[3].innerHTML.split(" "); if (tSize[1] == "KiB") { kib += parseFloat(tSize[0]); } else if (tSize[1] == "MiB") { mib += parseFloat(tSize[0]); } else if (tSize[1] == "GiB") { gib += parseFloat(tSize[0]); } }); var localTotal = kib + mib * 1000 + gib * 1000000; // Check if total has changed if (localTotal.toFixed(2) !== total) { if (localTotal < 1000) { total = localTotal.toFixed(2) + " KiB"; } else if (localTotal < 1000000) { total = (localTotal / 1000).toFixed(2) + " MiB"; } else if (localTotal < 1000000000) { total = (localTotal / 1000000).toFixed(2) + " GiB"; } else { total = (localTotal / 1000000000).toFixed(2) + " TiB"; } var selectedSizeTotal = document.getElementById("selectedSizeTotal"); selectedSizeTotal.innerHTML = "Selected Torrents Total: " + total; } // Update previousSelectedRows previousSelectedRows = Array.from(selectedRows); } } } // Run the function every 1 second var intervalId = setInterval(calculateTotal, 1000); // Helper function to compare two arrays function arraysAreEqual(array1, array2) { return array1.length === array2.length && array1.every((value, index) => value === array2[index]); } })();