Greasy Fork - Analyze from posted scripts

Shows the total amount for each rating, total/daily installs, and scripts posted on any user profile and search pages.

Versión del día 07/07/2024. Echa un vistazo a la versión más reciente.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         Greasy Fork - Analyze from posted scripts
// @namespace    ScriptAnalyzer
// @version      12
// @description  Shows the total amount for each rating, total/daily installs, and scripts posted on any user profile and search pages.
// @author       hacker09
// @match        https://greasyfork.org/*/users/*
// @match        https://greasyfork.org/*/scripts?q=*
// @match        https://greasyfork.org/*/scripts/by-site/*
// @icon         https://t2.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://greasyfork.org/&size=64
// @grant        none
// ==/UserScript==

(async function() {
  'use strict';
  var LatestCreated, LatestUpdated, ok, bad, good, DailyTotal, TotalInstalls, ScriptsArray, element, SignedIN = ''; //Create new variables

  const data = await (await fetch(document.querySelector('link[href$=".json"]').href)).json(); //Fetch and parse the response

  document.head.insertAdjacentHTML('beforeend', '<style>.list-option:not(.list-current) {display: flex; flex-direction: row; align-items: center;} .list-option:not(.list-current) > span {position: relative; left: -7px;} .list-option.list-current > span {position: relative; left: 5px;}</style>'); //Add a space before (

  location.href.match(/org\/.*\/scripts/) ? (element = ".width-constraint:nth-child(2)", ScriptsArray = data) : (element = "#user-script-sets-section, #user-script-list-section", ScriptsArray = document.querySelector('link[href$=".json"]').href.match(document.querySelector(".user-profile-link > a") !== null ? document.querySelector(".user-profile-link > a").innerText.toLowerCase() : false) ? (SignedIN = ' + Deleted + Unlisted + Libraries', data.scripts) : data.all_listable_scripts); //Get the current page element based on whether the current page is a script search page or not, and if the user is logged in or not

  LatestCreated = new Date(Math.max(...ScriptsArray.map(obj => new Date(obj.created_at)))); //Get the latest created script
  LatestUpdated = new Date(Math.max(...ScriptsArray.map(obj => new Date(obj.code_updated_at)))); //Get the latest updated script
  ok = ScriptsArray.map(obj => parseInt(obj.ok_ratings, 10)).reduce((acc, curr) => acc + curr, 0); //Sum the total amount of ok ratings
  bad = ScriptsArray.map(obj => parseInt(obj.bad_ratings, 10)).reduce((acc, curr) => acc + curr, 0); //Sum the total amount of bad ratings
  good = ScriptsArray.map(obj => parseInt(obj.good_ratings, 10)).reduce((acc, curr) => acc + curr, 0); //Sum the total amount of good ratings
  DailyTotal = ScriptsArray.map(obj => parseInt(obj.daily_installs, 10)).reduce((acc, curr) => acc + curr, 0); //Sum the total amount of daily total installs
  TotalInstalls = ScriptsArray.map(obj => parseInt(obj.total_installs, 10)).reduce((acc, curr) => acc + curr, 0); //Sum the total amount of total installs

  document.querySelector(element).insertAdjacentHTML("afterbegin", `<section><header><h3>Total</h3></header><section class="text-content"><ul><li><b>Script posts${SignedIN}</b>: ${ScriptsArray.length}</li><li><b>Daily installs</b>: ${DailyTotal.toLocaleString()}</li><li><b>Total installs</b>: ${TotalInstalls.toLocaleString()}</li><li><b>Total ok ratings</b>: ${ok.toLocaleString()}</li><li><b>Total bad ratings</b>: ${bad.toLocaleString()}</li><li><b>Total good ratings</b>: ${good.toLocaleString()}</li><li><b>Latest created</b>: ${LatestCreated}</li><li><b>Latest updated</b>: ${LatestUpdated}</li></ul></section></section>`); //Add the information on the page
  document.querySelector(".list-option").innerHTML += `<span>(${DailyTotal.toLocaleString()})</span>`; //Add the Dailytotal number on the sidebar
  document.querySelector(".list-option:nth-child(2)").innerHTML += `<span>(${TotalInstalls.toLocaleString()})</span>`; //Add the total number on the sidebar
  document.querySelector(".list-option:nth-child(3)").innerHTML += `<span>(${parseInt(ok+bad+good).toLocaleString()})</span>`; //Add the ratings number on the sidebar
})();