GreasyFork Total Scripts(modified)

Shows a user's total scripts count on GreasyFork(modified).

目前为 2022-02-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name GreasyFork Total Scripts(modified)
  3. // @namespace pxgamer
  4. // @version 0.2.9
  5. // @description Shows a user's total scripts count on GreasyFork(modified).
  6. // @author NotYou
  7. // @include *greasyfork.org/*/users/*
  8. // @include *greasyfork.org/*/scripts*
  9. // @include *sleazyfork.org/*/users/*
  10. // @include *sleazyfork.org/*/scripts*
  11. // @require https://code.jquery.com/jquery-1.7.2.min.js
  12. // @license GPL-3.0-or-later
  13. // @license-link https://www.gnu.org/licenses/gpl-3.0.txt
  14. // @grant none
  15. // ==/UserScript==
  16.  
  17. /* What's New?:
  18. * All languages support (https://greasyfork.org/en/scripts/20343/discussions/15913)
  19. * Displaying Total user's scripts near "Scripts"
  20. * Colours change parallel to the number count
  21. * jQuery bug fix
  22. * Total Scripts at search
  23. * Total Libraries at search
  24. * Include Sleazy Fork.
  25. * Works with local override.
  26. * Shows Total Styles
  27. * Total Libraries
  28. */
  29.  
  30. /* Script Update:
  31. * Better colors for low number for better visibility
  32. * Less Useless Code
  33. * Fixed Total Scripts at search
  34. * Better css identifying
  35. * Better js identifying
  36. * Better libraries identifying
  37. */
  38.  
  39. (function() {
  40. 'use strict';
  41.  
  42. let csstotal = document.querySelectorAll('[data-css-available-as-js="true"]').length;
  43. let libtotal = document.querySelectorAll('#user-library-script-list > li').length;
  44. let jstotal = document.querySelectorAll('#user-script-list > [data-css-available-as-js="false"]').length;
  45.  
  46. // Total Scripts
  47.  
  48. if (jstotal == 1) {
  49. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(125, 125, 125);font-variant: normal;"> [' + jstotal + ' Total Script]</span>');
  50. }
  51. else if(jstotal >= 100) {
  52. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(185, 16, 16);font-variant: normal;"> [' + jstotal + ' Total Scripts]</span>');
  53. }
  54. else if(jstotal >= 50) {
  55. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(185, 87, 16);font-variant: normal;"> [' + jstotal + ' Total Scripts]</span>');
  56. }
  57. else if(jstotal >= 25) {
  58. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(185, 159, 16);font-variant: normal;"> [' + jstotal + ' Total Scripts]</span>');
  59. }
  60. else if(jstotal >= 10) {
  61. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(21, 185, 16);font-variant: normal;"> [' + jstotal + ' Total Scripts]</span>');
  62. }
  63. else if(jstotal >= 5) {
  64. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(16, 185, 153);font-variant: normal;"> [' + jstotal + ' Total Scripts]</span>');
  65. }
  66. else if(jstotal > 1) {
  67. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(16, 42, 185);font-variant: normal;"> [' + jstotal + ' Total Scripts]</span>');
  68. }
  69. else if(jstotal < 0){
  70. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(213, 79, 79);font-variant: normal;"> [ Unexpected error! ]</span>');
  71. }
  72.  
  73. // Total Styles
  74.  
  75. if (csstotal == 1) {
  76. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(125, 125, 125);font-variant: normal;"> [' + csstotal + ' Total Style]</span>');
  77. }
  78. else if(csstotal >= 100) {
  79. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(185, 16, 16);font-variant: normal;"> [' + csstotal + ' Total Styles]</span>');
  80. }
  81. else if(csstotal >= 50) {
  82. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(185, 87, 16);font-variant: normal;"> [' + csstotal + ' Total Styles]</span>');
  83. }
  84. else if(csstotal >= 25) {
  85. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(185, 159, 16);font-variant: normal;"> [' + csstotal + ' Total Styles]</span>');
  86. }
  87. else if(csstotal >= 10) {
  88. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(21, 185, 16);font-variant: normal;"> [' + csstotal + ' Total Styles]</span>');
  89. }
  90. else if(csstotal >= 5) {
  91. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(16, 185, 153);font-variant: normal;"> [' + csstotal + ' Total Styles]</span>');
  92. }
  93. else if(csstotal > 1) {
  94. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(16, 42, 185);font-variant: normal;"> [' + csstotal + ' Total Styles]</span>');
  95. }
  96. else if(csstotal < 0){
  97. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(213, 79, 79);font-variant: normal;"> [ Unexpected error! ]</span>');
  98. }
  99.  
  100. // Total Libraries
  101.  
  102. if (libtotal == 1) {
  103. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(125, 125, 125);font-variant: normal;"> [' + libtotal + ' Total Library]</span>');
  104. }
  105. else if(libtotal >= 100) {
  106. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(185, 16, 16);font-variant: normal;"> [' + libtotal + ' Total Libraries]</span>');
  107. }
  108. else if(libtotal >= 50) {
  109. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(185, 87, 16);font-variant: normal;"> [' + libtotal + ' Total Libraries]</span>');
  110. }
  111. else if(libtotal >= 25) {
  112. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(185, 159, 16);font-variant: normal;"> [' + libtotal + ' Total Libraries]</span>');
  113. }
  114. else if(libtotal >= 10) {
  115. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(21, 185, 16);font-variant: normal;"> [' + libtotal + ' Total Libraries]</span>');
  116. }
  117. else if(libtotal >= 5) {
  118. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(16, 185, 153);font-variant: normal;"> [' + libtotal + ' Total Libraries]</span>');
  119. }
  120. else if(libtotal > 1) {
  121. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(16, 42, 185);font-variant: normal;"> [' + libtotal + ' Total Libraries]</span>');
  122. }
  123. else if(libtotal < 0){
  124. $('div.sidebarred-main-content h3:first').append('<span style="font-size: 15px;color: rgb(213, 79, 79);font-variant: normal;"> [ Unexpected error! ]</span>');
  125. }
  126. })();
  127.  
  128. // Total Libraries at search
  129. if(window.location.href.includes("/libraries?q=")||window.location.href.includes("/libraries?locale_override=1&q=")) {
  130. (function() {
  131. 'use strict';
  132.  
  133. let t = $('li[data-script-type="library"]').length;
  134. if (t == 1) {
  135. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(125, 125, 125);font-weight: bold;"> [' + t + ' Total Library]</span>');
  136. }
  137. else if(t >= 50) {
  138. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(185, 87, 16);font-weight: bold;"> [' + t + ' Total Libraries]</span>');
  139. }
  140. else if(t >= 25) {
  141. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(185, 159, 16);font-weight: bold;"> [' + t + ' Total Libraries]</span>');
  142. }
  143. else if(t >= 10) {
  144. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(21, 185, 16);font-weight: bold;"> [' + t + ' Total Libraries]</span>');
  145. }
  146. else if(t >= 5) {
  147. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(16, 185, 153);font-weight: bold;"> [' + t + ' Total Libraries]</span>');
  148. }
  149. else if(t > 1) {
  150. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(16, 42, 185);font-weight: bold;"> [' + t + ' Total Libraries]</span>');
  151. }
  152. else if(t < 0){
  153. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(213, 79, 79);font-weight: bold;"> [ Unexpected error! ]</span>');
  154. }
  155. })(); // Total Scripts at search
  156. } else if(window.location.href.includes("/scripts?q=")||(window.location.href.includes("/scripts?locale_override=1&q=")) != -1) {
  157. (function() {
  158. 'use strict';
  159.  
  160. let l = $('li[data-script-type]').length;
  161. if (l == 1) {
  162. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(125, 125, 125);font-weight: 700;"> [' + l + ' Total Script]</span>');
  163. }
  164. else if(l >= 50) {
  165. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(185, 87, 16);font-weight: 700;"> [' + l + ' Total Scripts]</span>');
  166. }
  167. else if(l >= 25) {
  168. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(185, 159, 16);font-weight: 700;"> [' + l + ' Total Scripts]</span>');
  169. }
  170. else if(l >= 10) {
  171. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(21, 185, 16);font-weight: 700;"> [' + l + ' Total Scripts]</span>');
  172. }
  173. else if(l >= 5) {
  174. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(16, 185, 153);font-weight: 700;"> [' + l + ' Total Scripts]</span>');
  175. }
  176. else if(l > 1) {
  177. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(16, 42, 185);font-weight: 700;"> [' + l + ' Total Scripts]</span>');
  178. }
  179. else if(l < 0){
  180. $('div.sidebarred-main-content p:first').append('<span style="font-size: 15px;color: rgb(213, 79, 79);font-weight: 700;"> [ Unexpected error! ]</span>');
  181. }
  182. })();
  183. }
  184.  
  185. // Log Message
  186. let csstotal = document.querySelectorAll('[data-script-language="css"]').length;
  187. let libtotal = document.querySelectorAll('#user-library-script-list > li').length;
  188. let jstotal = document.querySelectorAll('#user-script-list > [data-css-available-as-js="false"]').length;
  189. let t = $('li[data-script-type="library"]').length;
  190. let l = $('li[data-script-type]').length;
  191.  
  192. console.log('[Total Scripts: ' + jstotal + ']\n[Total Styles: ' + csstotal + ']\n[Total Libraries: ' + libtotal + ']\n[Total Libraries At Search: ' + t + ']\n[Total Scripts At Search: ' + l + ']')
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.