Greasy Fork - Analyze from posted scripts

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

当前为 2023-06-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Greasy Fork - Analyze from posted scripts
  3. // @namespace ScriptAnalyzer
  4. // @version 3
  5. // @description Shows the total amount for each ratings, total/daily installs, and scripts posted on any user profile and search pages.
  6. // @author hacker09
  7. // @match https://greasyfork.org/en/users/*
  8. // @match https://greasyfork.org/*/scripts?q=*
  9. // @match https://greasyfork.org/*/scripts/by-site/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (async function() {
  14. 'use strict';
  15. var date, ok = 0, bad = 0, Dailytotal = 0, total = 0, good = 0; //Create new variables
  16. document.querySelectorAll(".ok-rating-count").forEach(el => ok += parseInt(el.innerText)); //Add the ratings
  17. document.querySelectorAll(".bar-rating-count").forEach(el => bad += parseInt(el.innerText)); //Add the ratings
  18. document.querySelectorAll(".good-rating-count").forEach(el => good += parseInt(el.innerText)); //Add the ratings
  19. document.querySelectorAll("dd.script-list-total-installs").forEach(el => total += parseInt(el.innerText.replaceAll(',',''))); //Add the installs
  20. document.querySelectorAll("dd.script-list-daily-installs").forEach(el => Dailytotal += parseInt(el.innerText.replaceAll(',',''))); //Add the installs
  21.  
  22. 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 (
  23.  
  24. if (location.href.match('sort=created') === null) { //If the current page is not already being sorted by the created date
  25. date = await (await fetch(location.href + '?sort=created')).text(); //Fetch the page sorted by the created date
  26. date = new DOMParser().parseFromString(date, "text/html").querySelector("span > relative-time").innerText; //Save the newest created date
  27. } //Finishes the if condition
  28. else //If the current page is already being sorted by the created date
  29. { //Starts the else condition
  30. date = document.querySelector("relative-time").title; //Save the newest created date
  31. } //Finishes the else condition
  32.  
  33. if (location.href.match('users')) { //If the current page is a user profile
  34. document.querySelector("#user-script-sets-section,#user-script-list-section").insertAdjacentHTML("afterbegin", ` <section><header><h3>Total</h3></header><section class="text-content"><ul><li><b>Script posts</b>: ${document.querySelectorAll("#user-script-list > li").length}</li><li><b>Daily installs</b>: ${Dailytotal.toLocaleString()}</li><li><b>Total installs</b>: ${total.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>: ${date}</li></ul></section></section>`); //Add the information on the page
  35. document.querySelector(".list-option").innerHTML += `<span>(${Dailytotal.toLocaleString()})</span>`; //Add the Dailytotal information on the sidebar
  36. document.querySelector(".list-option:nth-child(2)").innerHTML += `<span>(${total.toLocaleString()})</span>`; //Add the total information on the sidebar
  37. document.querySelector(".list-option:nth-child(3)").innerHTML += `<span>(${ok+bad+good.toLocaleString()})</span>`; //Add the ratings information on the sidebar
  38. } //Finishes the if condition
  39. else //If the current page is a script search page
  40. { //Starts the else condition
  41. document.querySelector(".width-constraint:nth-child(2)").insertAdjacentHTML("afterbegin", ` <section><header><h3>Total</h3></header><section class="text-content"><ul><li><b>Script posts</b>: ${document.querySelectorAll("#browse-script-list > li").length}</li><li><b>Daily installs</b>: ${Dailytotal.toLocaleString()}</li><li><b>Total installs</b>: ${total.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>: ${date}</li></ul></section></section>`); //Add the information on the page
  42. document.querySelector(".list-option").innerHTML += `<span>(${Dailytotal.toLocaleString()})</span>`; //Add the Dailytotal information on the sidebar
  43. document.querySelector(".list-option:nth-child(2)").innerHTML += `<span>(${total.toLocaleString()})</span>`; //Add the total information on the sidebar
  44. document.querySelector(".list-option:nth-child(3)").innerHTML += `<span>(${ok+bad+good.toLocaleString()})</span>`; //Add the ratings information on the sidebar
  45. } //Finishes the else condition
  46. })();