Greasy Fork Total Installs(modified)

A userscript that shows the total installs for any page on Greasy Fork

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name Greasy Fork Total Installs(modified)
// @version 0.1.2
// @description A userscript that shows the total installs for any page on Greasy Fork
// @license MIT
// @namespace Rob Garrison
// @author Rob Garrison
// @modifiedBy NotYou
// @namespace https://github.com/Mottie
// @include https://greasyfork.org/*
// @run-at document-idle
// @grant none
// @icon https://greasyfork.org/packs/media/images/blacklogo96-b2384000fca45aa17e45eb417cbcbb59.png
// ==/UserScript==

/* What's New?
 *  Counts of total daily installs
 *  Replaced icon URL to new
 */

(() => {
	"use strict";

	const wrapper = $("#browse-script-list, #user-script-list");
	if (wrapper) {
        // CONSTANTAS //
		const els = [...wrapper.querySelectorAll("dd.script-list-total-installs")];
        const els2 = [...wrapper.querySelectorAll("dd.script-list-daily-installs")];
		const nonDigits = /[^\d]/g;
		const getNum = txt => parseFloat(txt.replace(nonDigits, ""));
		const total = els.reduce((acc, el) => acc + getNum(el.textContent), 0);
        const totald = els2.reduce((acc, el) => acc + getNum(el.textContent), 0); // NEW LET
        // IFs //
		if (total) {
			const span = document.createElement("span");
			let target = $("#script-list-sort .list-option:nth-child(2)");
			span.textContent = ` (${(total).toLocaleString()})`;
			if ($("a", target)) {
				target = $("a", target);
			}
			target.appendChild(span);
		}
        // MODIFICATION START //
        if (totald) {
			const span = document.createElement("span");
			let target = $("#script-list-sort .list-option:nth-child(1)");
			span.textContent = ` (${(totald).toLocaleString()})`;
			if ($("a", target)) {
				target = $("a", target);
			}
			target.appendChild(span);
		}
	}
    // MODIFICATION END //

    // FUNCTIONS //
	function $(str, el) {
		return (el || document).querySelector(str);
	}

})();