Greasy Fork Total Installs(modified)

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

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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);
	}

})();