// ==UserScript== // @name MAM Total Torrents // @namespace https://greasyfork.org/en/users/705546-yyyzzz999 // @version 0.2 // @license MIT // @description 9/10/22 Shows the total number of torrents on all clients // @author yyyzzz999 // @match https://www.myanonamouse.net/userClientDetails.php // @icon https://cdn.myanonamouse.net/imagebucket/164109/gsum.png // @homepage https://greasyfork.org/en/users/705546-yyyzzz999 // @grant none // @downloadURL none // ==/UserScript== /*jshint esversion: 6 */ /*eslint no-multi-spaces:0 */ (function() { 'use strict'; let DEBUG =1; // Debugging mode on (1) or off (0) let client_table = document.querySelector("div[class='blockBodyCon left']"); let links = client_table.getElementsByTagName('a'); // get all the client links let uns = document.querySelector("#tmUN"); let total = 0; if (links.length > 2) { for (let i = 2; i < links.length-1; i++) { if (links[i].href.match(/peers/)){ if (DEBUG > 0) console.log("i= "+ i + " " + links[i].innerText ); if (!isNaN(links[i].innerText)) total += parseInt(links[i].innerText); if (DEBUG > 0) console.log("Total: " + total); } } } let elb = document.querySelector("div[id='mainBody'] div[class='blockHeadCon']"); if (uns != null) { // Added check for Unsats shown in the top menu bar in MAM Main Menu Preferences let unsat = parseInt(uns.textContent.split(" ")[0]); const net = total - unsat; if (DEBUG > 0) console.log("net: " + net); elb.innerHTML = elb.innerHTML.replace('', '') + " | Total Torrents: " + total + " - Unsats = " + net + '' ; } else { // Unsats not shown elb.innerHTML = elb.innerHTML.replace('', '') + " | Total Torrents: " + total + '' ; } })();