Greasy Fork镜像 Total Installs(modified)

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

  1. // ==UserScript==
  2. // @name Greasy Fork镜像 Total Installs(modified)
  3. // @version 0.1.2
  4. // @description A userscript that shows the total installs for any page on Greasy Fork镜像
  5. // @license MIT
  6. // @namespace Rob Garrison
  7. // @author Rob Garrison
  8. // @modifiedBy NotYou
  9. // @namespace https://github.com/Mottie
  10. // @include https://gf.qytechs.cn/*
  11. // @run-at document-idle
  12. // @grant none
  13. // @icon https://gf.qytechs.cn/packs/media/images/blacklogo96-b2384000fca45aa17e45eb417cbcbb59.png
  14. // ==/UserScript==
  15.  
  16. /* What's New?
  17. * Counts of total daily installs
  18. * Replaced icon URL to new
  19. */
  20.  
  21. (() => {
  22. "use strict";
  23.  
  24. const wrapper = $("#browse-script-list, #user-script-list");
  25. if (wrapper) {
  26. // CONSTANTAS //
  27. const els = [...wrapper.querySelectorAll("dd.script-list-total-installs")];
  28. const els2 = [...wrapper.querySelectorAll("dd.script-list-daily-installs")];
  29. const nonDigits = /[^\d]/g;
  30. const getNum = txt => parseFloat(txt.replace(nonDigits, ""));
  31. const total = els.reduce((acc, el) => acc + getNum(el.textContent), 0);
  32. const totald = els2.reduce((acc, el) => acc + getNum(el.textContent), 0); // NEW LET
  33. // IFs //
  34. if (total) {
  35. const span = document.createElement("span");
  36. let target = $("#script-list-sort .list-option:nth-child(2)");
  37. span.textContent = ` (${(total).toLocaleString()})`;
  38. if ($("a", target)) {
  39. target = $("a", target);
  40. }
  41. target.appendChild(span);
  42. }
  43. // MODIFICATION START //
  44. if (totald) {
  45. const span = document.createElement("span");
  46. let target = $("#script-list-sort .list-option:nth-child(1)");
  47. span.textContent = ` (${(totald).toLocaleString()})`;
  48. if ($("a", target)) {
  49. target = $("a", target);
  50. }
  51. target.appendChild(span);
  52. }
  53. }
  54. // MODIFICATION END //
  55.  
  56. // FUNCTIONS //
  57. function $(str, el) {
  58. return (el || document).querySelector(str);
  59. }
  60.  
  61. })();
  62.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址