Greasy Fork User Statistics+

shows user statistics as total installs, total scripts and etc.

目前为 2022-02-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Greasy Fork User Statistics+
  3. // @namespace -
  4. // @version 0.1
  5. // @description shows user statistics as total installs, total scripts and etc.
  6. // @author NotYou
  7. // @include *greasyfork.org/*/users/*
  8. // @require https://code.jquery.com/jquery-3.3.1.min.js
  9. // @license GPL-3.0
  10. // @license-link https://www.gnu.org/licenses/gpl-3.0.txt
  11. // @grant GM_addStyle
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. let css = `
  16.  
  17. .numStat {
  18. margin-left: 0px;
  19. font-weight: 700 !important;
  20. font-size: 14px;
  21. }
  22.  
  23. .columnStat {
  24. background-color: rgba(0, 0, 0, 0.17);
  25. user-select: none !important;
  26. transition: 380ms;
  27. padding-left: 5px;
  28. padding-top: 5px;
  29. margin-top: 3px;
  30. display: block;
  31. height: 40px;
  32. border-radius: 0px 4px 4px 0px;
  33. }
  34.  
  35. .showMore {
  36. background: rgba(0, 0, 0, 0.17);
  37. color: currentColor !important;
  38. position: absolute;
  39. transition: 100ms;
  40. border-radius: 0px 5px 5px 0px;
  41. left: 92.4%;
  42. margin-top: -37px;
  43. cursor: default;
  44. padding: 8px;
  45. border-left: 2px solid currentColor;
  46. }
  47.  
  48. #user-statistics > span {
  49. font-weight: 700;
  50. }
  51.  
  52. #user-statistics > h3:nth-of-type(1):lang(ar)::before {
  53. content: "إحصائيات المستخدم";
  54. }
  55.  
  56. #user-statistics > h3:nth-of-type(2):lang(ar)::before {
  57. content: "يعمل المستخدم";
  58. }
  59.  
  60. #user-statistics > h3:nth-of-type(1):lang(bg)::before {
  61. content: "Потребителска статистика";
  62. }
  63.  
  64. #user-statistics > h3:nth-of-type(2):lang(bg)::before {
  65. content: "Потребителят работи";
  66. }
  67.  
  68. #user-statistics > h3:nth-of-type(1):lang(cs)::before {
  69. content: "Statistiky uživatelů";
  70. }
  71.  
  72. #user-statistics > h3:nth-of-type(2):lang(cs)::before {
  73. content: "Uživatel pracuje";
  74. }
  75.  
  76. #user-statistics > h3:nth-of-type(1):lang(da)::before {
  77. content: "Brugerstatistik";
  78. }
  79.  
  80. #user-statistics > h3:nth-of-type(2):lang(da)::before {
  81. content: "Brugeren fungerer";
  82. }
  83.  
  84. #user-statistics > h3:nth-of-type(1):lang(de)::before {
  85. content: "Benutzerstatistiken";
  86. }
  87.  
  88. #user-statistics > h3:nth-of-type(2):lang(de)::before {
  89. content: "Benutzer funktioniert";
  90. }
  91.  
  92. #user-statistics > h3:nth-of-type(1):lang(el)::before {
  93. content: "Στατιστικά στοιχεία χρηστών";
  94. }
  95.  
  96. #user-statistics > h3:nth-of-type(2):lang(el)::before {
  97. content: "Ο χρήστης λειτουργεί";
  98. }
  99.  
  100. #user-statistics > h3:nth-of-type(1):lang(en)::before {
  101. content: "User statistics";
  102. }
  103.  
  104. #user-statistics > h3:nth-of-type(2):lang(en)::before {
  105. content: "User works";
  106. }
  107.  
  108. #user-statistics > h3:nth-of-type(1):lang(eo)::before {
  109. content: "Statistiko de uzantoj";
  110. }
  111.  
  112. #user-statistics > h3:nth-of-type(2):lang(eo)::before {
  113. content: "Uzanto funkcias";
  114. }
  115.  
  116. #user-statistics > h3:nth-of-type(1):lang(es)::before {
  117. content: "Estadísticas de usuario";
  118. }
  119.  
  120. #user-statistics > h3:nth-of-type(2):lang(es)::before {
  121. content: "El usuario trabaja";
  122. }
  123.  
  124. #user-statistics > h3:nth-of-type(1):lang(fi)::before {
  125. content: "Käyttäjätilastot";
  126. }
  127.  
  128. #user-statistics > h3:nth-of-type(2):lang(fi)::before {
  129. content: "Käyttäjä toimii";
  130. }
  131.  
  132. #user-statistics > h3:nth-of-type(1):lang(fr)::before {
  133. content: "Statistiques d'utilisateurs";
  134. }
  135.  
  136. #user-statistics > h3:nth-of-type(2):lang(fr)::before {
  137. content: "L'utilisateur travaille";
  138. }
  139.  
  140. #user-statistics > h3:nth-of-type(1):lang(he)::before {
  141. content: "סטטיסטיקות משתמשים";
  142. }
  143.  
  144. #user-statistics > h3:nth-of-type(2):lang(he)::before {
  145. content: "משתמש עובד";
  146. }
  147.  
  148. #user-statistics > h3:nth-of-type(1):lang(hu)::before {
  149. content: "Felhasználói statisztikák";
  150. }
  151.  
  152. #user-statistics > h3:nth-of-type(2):lang(hu)::before {
  153. content: "Felhasználó működik";
  154. }
  155.  
  156. #user-statistics > h3:nth-of-type(1):lang(id)::before {
  157. content: "Statistik pengguna";
  158. }
  159.  
  160. #user-statistics > h3:nth-of-type(2):lang(id)::before {
  161. content: "Pengguna bekerja";
  162. }
  163.  
  164. #user-statistics > h3:nth-of-type(1):lang(it)::before {
  165. content: "Statistiche utente";
  166. }
  167.  
  168. #user-statistics > h3:nth-of-type(2):lang(it)::before {
  169. content: "L'utente lavora";
  170. }
  171.  
  172. #user-statistics > h3:nth-of-type(1):lang(ja)::before {
  173. content: "ユーザー統計";
  174. }
  175.  
  176. #user-statistics > h3:nth-of-type(2):lang(ja)::before {
  177. content: "ユーザーは動作します";
  178. }
  179.  
  180. #user-statistics > h3:nth-of-type(1):lang(ko)::before {
  181. content: "사용자 통계";
  182. }
  183.  
  184. #user-statistics > h3:nth-of-type(2):lang(ko)::before {
  185. content: "사용자 작품";
  186. }
  187.  
  188. #user-statistics > h3:nth-of-type(1):lang(ne)::before {
  189. content: "Gebruikersstatistieken";
  190. }
  191.  
  192. #user-statistics > h3:nth-of-type(2):lang(ne)::before {
  193. content: "Gebruiker werkt";
  194. }
  195.  
  196. #user-statistics > h3:nth-of-type(1):lang(pl)::before {
  197. content: "Statystyki użytkowników";
  198. }
  199.  
  200. #user-statistics > h3:nth-of-type(2):lang(pl)::before {
  201. content: "Użytkownik pracuje";
  202. }
  203.  
  204. #user-statistics > h3:nth-of-type(1):lang(ro)::before {
  205. content: "Statistici utilizatori";
  206. }
  207.  
  208. #user-statistics > h3:nth-of-type(2):lang(ro)::before {
  209. content: "Utilizatorul lucrează";
  210. }
  211.  
  212. #user-statistics > h3:nth-of-type(1):lang(ru)::before {
  213. content: "Статистика пользователей";
  214. }
  215.  
  216. #user-statistics > h3:nth-of-type(2):lang(ru)::before {
  217. content: "Пользовательские работы";
  218. }
  219.  
  220. #user-statistics > h3:nth-of-type(1):lang(tr)::before {
  221. content: "Kullanıcı istatistikleri";
  222. }
  223.  
  224. #user-statistics > h3:nth-of-type(2):lang(tr)::before {
  225. content: "Kullanıcı işleri";
  226. }
  227.  
  228. #user-statistics > h3:nth-of-type(1):lang(uk)::before {
  229. content: "Статистика користувачів";
  230. }
  231.  
  232. #user-statistics > h3:nth-of-type(2):lang(uk)::before {
  233. content: "Користувач працює";
  234. }
  235.  
  236. #user-statistics > h3:nth-of-type(1):lang(vi)::before {
  237. content: "Thống kê người dùng";
  238. }
  239.  
  240. #user-statistics > h3:nth-of-type(2):lang(vi)::before {
  241. content: "Người dùng hoạt động";
  242. }
  243.  
  244. #user-statistics > h3:nth-of-type(1):lang(zh-CN)::before {
  245. content: "用户统计";
  246. }
  247.  
  248. #user-statistics > h3:nth-of-type(2):lang(zh-CN)::before {
  249. content: "用户作品";
  250. }
  251.  
  252. #user-statistics > h3:nth-of-type(1):lang(zh-TW)::before {
  253. content: "用戶統計";
  254. }
  255.  
  256. #user-statistics > h3:nth-of-type(2):lang(zh-TW)::before {
  257. content: "用戶作品";
  258. }
  259.  
  260. #user-statistics > h3:nth-of-type(1)::before {
  261. content: "User statistics";
  262. }
  263.  
  264. #user-statistics > h3:nth-of-type(2)::before {
  265. content: "User works";
  266. }
  267.  
  268. `;
  269. if (typeof GM_addStyle !== "undefined") {
  270. GM_addStyle(css);
  271. } else {
  272. let styleNode = document.createElement("style");
  273. styleNode.appendChild(document.createTextNode(css));
  274. (document.querySelector("head") || document.documentElement).appendChild(styleNode);
  275. }
  276. })();
  277.  
  278. /* START OF MIT LICENSE | Source: https://greasyfork.org/scripts/438584/code */
  279. const wrapper = document.querySelector("#browse-script-list, #user-script-list");
  280. const els = [...wrapper.querySelectorAll("dd.script-list-total-installs")];
  281. const els2 = [...wrapper.querySelectorAll("dd.script-list-daily-installs")];
  282. const nonDigits = /[^\d]/g;
  283. const getNum = txt => parseFloat(txt.replace(nonDigits, ""));
  284. const totalDownloads = els.reduce((acc, el) => acc + getNum(el.textContent), 0);
  285. const totalDailyDownloads = els2.reduce((acc, el) => acc + getNum(el.textContent), 0);
  286. const totalDownloadsStat = els.reduce((acc, el) => acc + getNum(el.textContent), 0);
  287. const totalDailyDownloadsStat = els2.reduce((acc, el) => acc + getNum(el.textContent), 0);
  288. /* END OF MIT LICENSE */
  289.  
  290. if(totalDownloads > 800) {
  291. var totalDownloadsTotal = '';
  292. } else if(totalDownloads == 0) {
  293. var totalDownloadsTotal = '0'
  294. } else if(totalDownloads < 800) {
  295. var totalDownloadsTotal = totalDownloads;
  296. }
  297.  
  298. if(totalDailyDownloads > 800) {
  299. var totalDailyDownloadsTotal = '';
  300. } else if(totalDailyDownloads == 0) {
  301. var totalDailyDownloadsTotal = '0'
  302. } else if(totalDailyDownloads < 800) {
  303. var totalDailyDownloadsTotal = totalDailyDownloads;
  304. }
  305.  
  306. let cssStat = document.querySelectorAll('[data-css-available-as-js="true"]').length; var cssTotal = cssStat * 4;
  307. let libStat = document.querySelectorAll('#user-library-script-list > li').length; var libTotal = libStat * 4;
  308. let jsStat = document.querySelectorAll('#user-script-list > [data-css-available-as-js="false"]').length; var jsTotal = jsStat * 4;
  309.  
  310. $('#about-user').append(`<section id="user-statistics">
  311. <h3></h3>
  312. <span id="column0" class="columnStat">Total Installs</span><span id="column0More" class="showMore">`+totalDownloadsStat+`</span>
  313. <span id="column1" class="columnStat">Daily Installs</span><span id="column1More" class="showMore">`+totalDailyDownloadsStat+`</span>
  314. <h3></h3>
  315. <span id="column2" class="columnStat">Total Scripts</span><span id="column2More" class="showMore">`+jsStat+`</span>
  316. <span id="column3" class="columnStat">Total Styles</span><span id="column3More" class="showMore">`+cssStat+`</span>
  317. <span id="column4" class="columnStat">Total Libraries</span><span id="column4More" class="showMore">`+libStat+`</span>
  318. </section>`);
  319.  
  320. (function() {
  321. let css = `
  322. #column0 {
  323. width: 0px;
  324. }
  325.  
  326. #column1 {
  327. width: 0px;
  328. }
  329.  
  330. #column2 {
  331. width: 0px;
  332. }
  333.  
  334. #column3 {
  335. width: 0px;
  336. }
  337.  
  338. #column4 {
  339. width: 0px;
  340. }
  341. `;
  342. if (typeof GM_addStyle !== "undefined") {
  343. GM_addStyle(css);
  344. } else {
  345. let styleNode = document.createElement("style");
  346. styleNode.appendChild(document.createTextNode(css));
  347. (document.querySelector("head") || document.documentElement).appendChild(styleNode);
  348. }
  349. })();
  350.  
  351. if(totalDownloadsTotal == "") {
  352. totalDownloadsTotal = '92%'
  353. } else {
  354. totalDownloadsTotal = totalDownloadsTotal+'px'
  355. }
  356.  
  357. if(totalDailyDownloadsTotal == "") {
  358. totalDailyDownloadsTotal = '92%'
  359. } else {
  360. totalDailyDownloadsTotal = totalDailyDownloadsTotal+'px'
  361. }
  362.  
  363. function columnsStart() {
  364. (function() {
  365. let css = `
  366.  
  367. #column0 {
  368. width: `+totalDownloadsTotal+` !important;
  369. }
  370.  
  371. #column1 {
  372. width: `+totalDailyDownloadsTotal+` !important;
  373. }
  374.  
  375. #column2 {
  376. width: `+jsTotal+`px;
  377. }
  378.  
  379. #column3 {
  380. width: `+cssTotal+`px;
  381. }
  382.  
  383. #column4 {
  384. width: `+libTotal+`px;
  385. }
  386.  
  387. `;
  388. if (typeof GM_addStyle !== "undefined") {
  389. GM_addStyle(css);
  390. } else {
  391. let styleNode = document.createElement("style");
  392. styleNode.appendChild(document.createTextNode(css));
  393. (document.querySelector("head") || document.documentElement).appendChild(styleNode);
  394. }})();
  395. }
  396. setTimeout(columnsStart, 300)
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.