GreasyFork Bullshit Filter

Hides scripts for popular browser games and social networks as well as scripts that use "foreign" characters in descriptions. Applies to posts in Forum too.

当前为 2017-11-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GreasyFork Bullshit Filter
  3. // @namespace darkred
  4. // @author kuehlschrank, darkred
  5. // @license MIT
  6. // @description Hides scripts for popular browser games and social networks as well as scripts that use "foreign" characters in descriptions. Applies to posts in Forum too.
  7. // @version 2017.5.18
  8. // @icon https://s3.amazonaws.com/uso_ss/icon/97145/large.png
  9. // @include https://greasyfork.org/*/scripts*
  10. // @exclude /^https:\/\/greasyfork.org\/.*\/scripts\/\d+.*/
  11. // @exclude https://greasyfork.org/*/scripts/by-site
  12. // @exclude https://greasyfork.org/*/scripts/by-site?*
  13. // @include https://greasyfork.org/*/forum*
  14. // @exclude https://greasyfork.org/*/forum/discussion/*
  15. // @exclude https://greasyfork.org/*/forum/profile*
  16. // @exclude https://greasyfork.org/*/forum/messages*
  17. // @exclude https://greasyfork.org/*/forum/categories
  18. // @grant none
  19. // This is an edited version of this script (http://userscripts-mirror.org/scripts/show/97145) by kuehlschrank.
  20. // Thanks a lot to kuehlschrank for making another great script.
  21. // ==/UserScript==
  22.  
  23.  
  24. if (window.location.href.indexOf('forum') === -1) {
  25. (function() {
  26. var filters = {
  27. 'Non-ASCII': /[^\x00-\x7F\s]+/i,
  28. 'Games': /AntiGame|Agar|agar\.io|alis\.io|angel\.io|ExtencionRipXChetoMalo|AposBot|DFxLite|ZTx-Lite|AposFeedingBot|AposLoader|Blah Blah|Orc Clan Script|Astro\s*Empires|^\s*Attack|^\s*Battle|BiteFight|Blood\s*Wars|Bots|Bots4|Brawler|\bBvS\b|Business\s*Tycoon|Castle\s*Age|City\s*Ville|chopcoin\.io|Comunio|Conquer\s*Club|CosmoPulse|cursors\.io|Dark\s*Orbit|Dead\s*Frontier|Diep\.io|\bDOA\b|doblons\.io|DotD|Dossergame|Dragons\s*of\s*Atlantis|driftin\.io|Dugout|\bDS[a-z]+\n|elites\.io|Empire\s*Board|eRep(ublik)?|Epic.*War|ExoPlanet|Falcon Tools|Feuerwache|Farming|FarmVille|Fightinfo|Frontier\s*Ville|Ghost\s*Trapper|Gladiatus|Goalline|Gondal|gota\.io|Grepolis|Hobopolis|\bhwm(\b|_)|Ikariam|\bIT2\b|Jellyneo|Kapi\s*Hospital|Kings\s*Age|Kingdoms?\s*of|knastv(ö|oe)gel|Knight\s*Fight|\b(Power)?KoC(Atta?ck)?\b|\bKOL\b|Kongregate|Last\s*Emperor|Legends?\s*of|Light\s*Rising|lite\.ext\.io|Lockerz|\bLoU\b|Mafia\s*(Wars|Mofo)|Menelgame|Mob\s*Wars|Mouse\s*Hunt|Molehill\s*Empire|NeoQuest|MyFreeFarm|narwhale\.io|Neopets|Nemexia|\bOGame\b|Ogar(io)?|Pardus|Pennergame|Pigskin\s*Empire|PlayerScripts|pokeradar\.io|Popmundo|Po?we?r\s*(Bot|Tools)|PsicoTSI|Ravenwood|Schulterglatze|slither\.io|slitherplus\.io|slitheriogameplay|SpaceWars|splix\.io|\bSW_[a-z]+\n|\bSnP\b|The\s*Crims|The\s*West|torto\.io|Travian|Treasure\s*Isl(and|e)|Tribal\s*Wars|TW.?PRO|Vampire\s*Wars|vertix\.io|War\s*of\s*Ninja|West\s*Wars|wings\.io|\bWoD\b|World\s*of\s*Dungeons|wtf\s*battles|Wurzelimperium/i,
  29. 'Social Networks': /Face\s*book|Google(\+| Plus)|\bHabbo|Kaskus|\bLepra|Leprosorium|MySpace|meinVZ|odnoklassniki|Одноклассники|Orkut|sch(ue|ü)ler(VZ|\.cc)?|studiVZ|Unfriend|Valenth|VK|vkontakte|ВКонтакте|Qzone|Twitter|TweetDeck/i,
  30. 'Clutter': /^\s*(.{1,3})\1+\n|^\s*(.+?)\n+\2\n*$|^\s*.{1,5}\n|do\s*n('|o)?t (install|download)|nicht installieren|just(\s*a)?\s*test|^\s*.{0,4}test.{0,4}\n|\ntest(ing)?\s*|^\s*(\{@|Smolka|Hacks)|\[\d{4,5}\]|free\s*download/i
  31. };
  32. if (typeof GM_getValue == 'undefined' || (typeof GM_getValue.toString == 'function' && GM_getValue.toString().indexOf('not supported') > -1)) {
  33. GM_getValue = my_GM_getValue;
  34. GM_setValue = my_GM_setValue;
  35. }
  36. insertStyle();
  37. insertStatus();
  38. filterScripts();
  39. insertSwitches();
  40.  
  41. // Note: you may uncomment line 35 (and comment out line 36), in order the filtered scripts to be highlighted khaki -instead of hiding them- so that you can check which scripts have been filtered
  42. function insertStyle() {
  43. var style = document.createElement('style');
  44. // style.textContent = 'li.filtered { background-color:khaki; !important;} .filter-status { margin-left: 6px; } .filter-switches { display:none; } *:hover > .filter-switches { display:block !important; } .filter-on, .filter-off {display:block !important; width: 97px;}} .filter-switches a { text-decoration:none !important; color:inherit; cursor:pointer; } .filter-switches a { margin-left: 8px; padding: 0 4px; } a.filter-on { background-color:#ffcccc; color:#333333; text-decoration:line-through !important } a.filter-off { background-color:#ccffcc; color:#333333 } ';
  45. style.textContent = 'li.filtered { display:none !important; } .filter-status { margin-left: 6px; } .filter-switches { display:none; } *:hover > .filter-switches { display:block !important; } .filter-on, .filter-off {display:block !important; width: 97px;}} .filter-switches a { text-decoration:none !important; color:inherit; cursor:pointer; } .filter-switches a { margin-left: 8px; padding: 0 4px; } a.filter-on { background-color:#ffcccc; color:#333333; text-decoration:line-through !important } a.filter-off { background-color:#ccffcc; color:#333333 } ';
  46. style.type = 'text/css';
  47. document.querySelector('head').appendChild(style);
  48. }
  49.  
  50. function insertStatus() {
  51. var p = document.querySelector('#script-list-option-groups');
  52. if (p) {
  53. var status = document.createElement('span');
  54. status.className = 'filter-status';
  55. p.appendChild(status);
  56. }
  57. }
  58.  
  59. function filterScripts() {
  60. var activeFilters = [];
  61. for (var filter in filters) {
  62. if (filters.hasOwnProperty(filter) && GM_getValue(filter, 'on') == 'on') {
  63. activeFilters.push(filters[filter]);
  64. }
  65. }
  66. var nodes = document.querySelectorAll('article > h2'),
  67. numActiveFilters = activeFilters.length,
  68. numFiltered = 0;
  69. for (var i = 0, numNodes = nodes.length, td = null; i < numNodes && (td = nodes[i]); i++) {
  70. td.parentNode.parentNode.classList.remove('filtered');
  71. for (var j = 0; j < numActiveFilters; j++) {
  72. if (td.innerText.match(activeFilters[j])) {
  73. td.parentNode.parentNode.classList.add('filtered');
  74. numFiltered++;
  75. break;
  76. }
  77. }
  78. }
  79. document.querySelector('.filter-status').textContent = document.querySelectorAll('article > h2').length - numFiltered + ' scripts (' + numFiltered + ' filtered)';
  80. }
  81.  
  82. function insertSwitches() {
  83. var span = document.createElement('span');
  84. span.className = 'filter-switches';
  85. for (var filter in filters) {
  86. if (filters.hasOwnProperty(filter)) {
  87. span.appendChild(createSwitch(filter, GM_getValue(filter, 'on') == 'on'));
  88. }
  89. }
  90. document.querySelector('.filter-status').parentNode.appendChild(span);
  91. }
  92.  
  93. function createSwitch(label, isOn) {
  94. var a = document.createElement('a');
  95. a.className = isOn ? 'filter-on' : 'filter-off';
  96. a.textContent = label;
  97. a.addEventListener('click', function(e) {
  98. if (this.className == 'filter-on') {
  99. this.className = 'filter-off';
  100. GM_setValue(this.textContent, 'off');
  101. } else {
  102. this.className = 'filter-on';
  103. GM_setValue(this.textContent, 'on');
  104. }
  105. filterScripts();
  106. e.preventDefault();
  107. }, false);
  108. return a;
  109. }
  110.  
  111. function my_GM_setValue(name, value) {
  112. localStorage.setItem(name, value);
  113. }
  114.  
  115. function my_GM_getValue(name, defaultValue) {
  116. var value;
  117. if (!(value = localStorage.getItem(name))) {
  118. return defaultValue;
  119. }
  120. return value;
  121. }
  122. })();
  123.  
  124. } else {
  125.  
  126. (function() {
  127. var filters = {
  128. 'Non-ASCII': /[^\x00-\x7F\s]+/i,
  129. 'Games': /AntiGame|Agar|agar\.io|alis\.io|angel\.io|ExtencionRipXChetoMalo|AposBot|DFxLite|ZTx-Lite|AposFeedingBot|AposLoader|Blah Blah|Orc Clan Script|Astro\s*Empires|^\s*Attack|^\s*Battle|BiteFight|Blood\s*Wars|Bots|Bots4|Brawler|\bBvS\b|Business\s*Tycoon|Castle\s*Age|City\s*Ville|chopcoin\.io|Comunio|Conquer\s*Club|CosmoPulse|cursors\.io|Dark\s*Orbit|Dead\s*Frontier|Diep\.io|\bDOA\b|doblons\.io|DotD|Dossergame|Dragons\s*of\s*Atlantis|driftin\.io|Dugout|\bDS[a-z]+\n|elites\.io|Empire\s*Board|eRep(ublik)?|Epic.*War|ExoPlanet|Falcon Tools|Feuerwache|Farming|FarmVille|Fightinfo|Frontier\s*Ville|Ghost\s*Trapper|Gladiatus|Goalline|Gondal|gota\.io|Grepolis|Hobopolis|\bhwm(\b|_)|Ikariam|\bIT2\b|Jellyneo|Kapi\s*Hospital|Kings\s*Age|Kingdoms?\s*of|knastv(ö|oe)gel|Knight\s*Fight|\b(Power)?KoC(Atta?ck)?\b|\bKOL\b|Kongregate|Last\s*Emperor|Legends?\s*of|Light\s*Rising|lite\.ext\.io|Lockerz|\bLoU\b|Mafia\s*(Wars|Mofo)|Menelgame|Mob\s*Wars|Mouse\s*Hunt|Molehill\s*Empire|NeoQuest|MyFreeFarm|narwhale\.io|Neopets|Nemexia|\bOGame\b|Ogar(io)?|Pardus|Pennergame|Pigskin\s*Empire|PlayerScripts|pokeradar\.io|Popmundo|Po?we?r\s*(Bot|Tools)|PsicoTSI|Ravenwood|Schulterglatze|slither\.io|slitherplus\.io|slitheriogameplay|SpaceWars|splix\.io|\bSW_[a-z]+\n|\bSnP\b|The\s*Crims|The\s*West|torto\.io|Travian|Treasure\s*Isl(and|e)|Tribal\s*Wars|TW.?PRO|Vampire\s*Wars|vertix\.io|War\s*of\s*Ninja|West\s*Wars|wings\.io|\bWoD\b|World\s*of\s*Dungeons|wtf\s*battles|Wurzelimperium/i,
  130. 'Social Networks': /Face\s*book|Google(\+| Plus)|\bHabbo|Kaskus|\bLepra|Leprosorium|MySpace|meinVZ|odnoklassniki|Одноклассники|Orkut|sch(ue|ü)ler(VZ|\.cc)?|studiVZ|Unfriend|Valenth|VK|vkontakte|ВКонтакте|Qzone|Twitter|TweetDeck/i,
  131. 'Clutter': /^\s*(.{1,3})\1+\n|^\s*(.+?)\n+\2\n*$|^\s*.{1,5}\n|do\s*n('|o)?t (install|download)|nicht installieren|just(\s*a)?\s*test|^\s*.{0,4}test.{0,4}\n|\ntest(ing)?\s*|^\s*(\{@|Smolka|Hacks)|\[\d{4,5}\]|free\s*download/i
  132. };
  133. if (typeof GM_getValue == 'undefined' || (typeof GM_getValue.toString == 'function' && GM_getValue.toString().indexOf('not supported') > -1)) {
  134. GM_getValue = my_GM_getValue;
  135. GM_setValue = my_GM_setValue;
  136. }
  137. insertStyle();
  138. insertStatus();
  139. filterScripts();
  140. insertSwitches();
  141.  
  142. // Note: you may uncomment line 35 (and comment out line 36), in order the filtered scripts to be highlighted khaki -instead of hiding them- so that you can check which scripts have been filtered
  143. function insertStyle() {
  144. var style = document.createElement('style');
  145. // style.textContent = '.ItemDiscussion.filtered { background-color:khaki !important;} .filter-status { margin-left: 6px; } .filter-switches { display:none; } *:hover > .filter-switches { display:block !important; } .filter-on, .filter-off {display:block !important; width: 97px;}} .filter-switches a { text-decoration:none !important; color:inherit; cursor:pointer; } .filter-switches a { margin-left: 8px; padding: 0 4px; } a.filter-on { background-color:#ffcccc; color:#333333; text-decoration:line-through !important } a.filter-off { background-color:#ccffcc; color:#333333 } ';
  146. style.textContent = '.ItemDiscussion.filtered { display:none !important; } .filter-status { margin-left: 6px; } .filter-switches { display:none; } *:hover > .filter-switches { display:block !important; } .filter-on, .filter-off {display:block !important; width: 97px;}} .filter-switches a { text-decoration:none !important; color:inherit; cursor:pointer; } .filter-switches a { margin-left: 8px; padding: 0 4px; } a.filter-on { background-color:#ffcccc; color:#333333; text-decoration:line-through !important } a.filter-off { background-color:#ccffcc; color:#333333 } .filter-on, .filter-off { color: black !important;} ';
  147. style.type = 'text/css';
  148. document.querySelector('head').appendChild(style);
  149. }
  150.  
  151. function insertStatus() {
  152. var p = document.querySelector('#Head');
  153. if (p) {
  154. var status = document.createElement('span');
  155. status.className = 'filter-status';
  156. p.appendChild(status);
  157. }
  158. }
  159.  
  160. function filterScripts() {
  161. var activeFilters = [];
  162. for (var filter in filters) {
  163. if (filters.hasOwnProperty(filter) && GM_getValue(filter, 'on') == 'on') {
  164. activeFilters.push(filters[filter]);
  165. }
  166. }
  167. var nodes = document.querySelectorAll('.ItemDiscussion'),
  168. numActiveFilters = activeFilters.length,
  169. numFiltered = 0;
  170. for (var i = 0, numNodes = nodes.length, td = null; i < numNodes && (td = nodes[i]); i++) {
  171. td.classList.remove('filtered');
  172. for (var j = 0; j < numActiveFilters; j++) {
  173. var temp = td.children[1].firstElementChild.innerText;
  174. if(temp.match(activeFilters[j])) {
  175. td.classList.add('filtered');
  176. numFiltered++;
  177. break;
  178. }
  179. }
  180. }
  181. document.querySelector('.filter-status').innerText = (document.querySelectorAll('.ItemDiscussion').length - numFiltered) + ' discussions (' + numFiltered + ' filtered)';
  182. }
  183.  
  184. function insertSwitches() {
  185. var span = document.createElement('span');
  186. span.className = 'filter-switches';
  187. for (var filter in filters) {
  188. if (filters.hasOwnProperty(filter)) {
  189. span.appendChild(createSwitch(filter, GM_getValue(filter, 'on') == 'on'));
  190. }
  191. }
  192. document.querySelector('.filter-status').parentNode.appendChild(span);
  193. }
  194.  
  195. function createSwitch(label, isOn) {
  196. var a = document.createElement('a');
  197. a.className = isOn ? 'filter-on' : 'filter-off';
  198. a.textContent = label;
  199. a.addEventListener('click', function(e) {
  200. if (this.className == 'filter-on') {
  201. this.className = 'filter-off';
  202. GM_setValue(this.textContent, 'off');
  203. } else {
  204. this.className = 'filter-on';
  205. GM_setValue(this.textContent, 'on');
  206. }
  207. filterScripts();
  208. e.preventDefault();
  209. }, false);
  210. return a;
  211. }
  212.  
  213. function my_GM_setValue(name, value) {
  214. localStorage.setItem(name, value);
  215. }
  216.  
  217. function my_GM_getValue(name, defaultValue) {
  218. var value;
  219. if (!(value = localStorage.getItem(name))) {
  220. return defaultValue;
  221. }
  222. return value;
  223. }
  224. })();
  225.  
  226.  
  227.  
  228.  
  229. }