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.

安裝腳本?
作者推薦腳本

您可能也會喜歡 Better GreasyFork Forum

安裝腳本
  1. // ==UserScript==
  2. // @name Greasy Fork - Analyze from posted scripts
  3. // @namespace ScriptAnalyzer
  4. // @version 14
  5. // @description Shows the total amount for each rating, total/daily installs, and scripts posted on any user profile and search pages.
  6. // @author hacker09
  7. // @match https://greasyfork.org/*/users/*
  8. // @match https://greasyfork.org/*/scripts?q=*
  9. // @match https://greasyfork.org/*/scripts/by-site/*
  10. // @icon https://t2.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://greasyfork.org/&size=64
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (async function() {
  15. 'use strict';
  16. const data = await (await fetch(document.querySelector('link[href$=".json"]').href)).json(); //Fetch and parse the response
  17. var LatestCreated, LatestUpdated, ok, bad, good, DailyTotal, TotalInstalls, element, SignedIN, ScriptsArray = data.scripts; //Create new variables
  18.  
  19. SignedIN = document.querySelector('.user-profile-link a')?.href.match(/\d+/)[0] === String(data.id) ? ' + Deleted + Unlisted + Libraries' : ''; //If the user is on their own profile page
  20. element = location.href.match(/org\/.*\/scripts/) ? ".width-constraint:nth-child(2)" : "#user-script-sets-section, #user-script-list-section"; //If the current page is a script search page
  21.  
  22. LatestCreated = new Date(Math.max(...ScriptsArray.map(obj => new Date(obj.created_at)))); //Get the latest created script
  23. LatestUpdated = new Date(Math.max(...ScriptsArray.map(obj => new Date(obj.code_updated_at)))); //Get the latest updated script
  24. ok = ScriptsArray.map(obj => obj.ok_ratings).reduce((acc, curr) => acc + curr, 0); //Sum the total amount of ok ratings
  25. bad = ScriptsArray.map(obj => obj.bad_ratings).reduce((acc, curr) => acc + curr, 0); //Sum the total amount of bad ratings
  26. good = ScriptsArray.map(obj => obj.good_ratings).reduce((acc, curr) => acc + curr, 0); //Sum the total amount of good ratings
  27. DailyTotal = ScriptsArray.map(obj => obj.daily_installs).reduce((acc, curr) => acc + curr, 0); //Sum the total amount of daily total installs
  28. TotalInstalls = ScriptsArray.map(obj => obj.total_installs).reduce((acc, curr) => acc + curr, 0); //Sum the total amount of total installs
  29.  
  30. document.querySelector(element).insertAdjacentHTML("afterbegin", `<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> <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
  31. document.querySelector(".list-option").innerHTML += `<span>(${DailyTotal.toLocaleString()})</span>`; //Add the Dailytotal number on the sidebar
  32. document.querySelector(".list-option:nth-child(2)").innerHTML += `<span>(${TotalInstalls.toLocaleString()})</span>`; //Add the total number on the sidebar
  33. document.querySelector(".list-option:nth-child(3)").innerHTML += `<span>(${ok+bad+good.toLocaleString()})</span>`; //Add the ratings number on the sidebar
  34. })();