Greasy-fork-total-installs

Show total installs

Ekde 2017/09/09. Vidu La ĝisdata versio.

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
// @version     0.1.0
// @description Show total installs
// @license     MIT
// @author      Rob Garrison
// @namespace   https://github.com/Mottie
// @include     https://greasyfork.org/*
// @run-at      document-idle
// @grant       none
// @icon        https://greasyfork.org/assets/blacklogo16-bc64b9f7afdc9be4cbfa58bdd5fc2e5c098ad4bca3ad513a27b15602083fd5bc.png
// ==/UserScript==
(function() {
  "use strict";

  const wrapper = document.querySelector("#browse-script-list, #user-script-list");
  if (wrapper) {
    const els = [...wrapper.querySelectorAll("dd.script-list-total-installs")];
    const total = els.reduce((acc, el) => acc + parseFloat(el.textContent.replace(/[^\d]/g, "")), 0);
    if (total) {
      const span = document.createElement("span");
      let target = document.querySelector('#script-list-sort .list-option:nth-child(2)');
      span.textContent = ` (${(total).toLocaleString()})`;
      if (target.querySelector("a")) {
        target = target.querySelector("a");
      }
      target.appendChild(span);
	}
  }
})();