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-05-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GreasyFork Bullshit Filter
  3. // @namespace darkred
  4. // @author kuehlschrank, darkred
  5. // @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.
  6. // @version 2017.5.16.1
  7. // @icon https://s3.amazonaws.com/uso_ss/icon/97145/large.png
  8. // @grant none
  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. // This is an edited version of this script (http://userscripts-mirror.org/scripts/show/97145) by kuehlschrank.
  19. // Thanks a lot to kuehlschrank for making another great script.
  20. // ==/UserScript==
  21.  
  22.  
  23. if (window.location.href.indexOf('forum') === -1) {
  24. (function() {
  25. var filters = {
  26. 'Non-ASCII': /[^\x00-\x7F\s]+/i,
  27. '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,
  28. '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,
  29. '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
  30. };
  31. if (typeof GM_getValue == 'undefined' || (typeof GM_getValue.toString == 'function' && GM_getValue.toString().indexOf('not supported') > -1)) {
  32. GM_getValue = my_GM_getValue;
  33. GM_setValue = my_GM_setValue;
  34. }
  35. insertStyle();
  36. insertStatus();
  37. filterScripts();
  38. insertSwitches();
  39.  
  40. // 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
  41. function insertStyle() {
  42. var style = document.createElement('style');
  43. // 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 } ';
  44. 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 } ';
  45. style.type = 'text/css';
  46. document.querySelector('head').appendChild(style);
  47. }
  48.  
  49. function insertStatus() {
  50. var p = document.querySelector('#script-list-option-groups');
  51. if (p) {
  52. var status = document.createElement('span');
  53. status.className = 'filter-status';
  54. p.appendChild(status);
  55. }
  56. }
  57.  
  58. function filterScripts() {
  59. var activeFilters = [];
  60. for (var filter in filters) {
  61. if (filters.hasOwnProperty(filter) && GM_getValue(filter, 'on') == 'on') {
  62. activeFilters.push(filters[filter]);
  63. }
  64. }
  65. var nodes = document.querySelectorAll('article > h2'),
  66. numActiveFilters = activeFilters.length,
  67. numFiltered = 0;
  68. for (var i = 0, numNodes = nodes.length, td = null; i < numNodes && (td = nodes[i]); i++) {
  69. td.parentNode.parentNode.classList.remove('filtered');
  70. for (var j = 0; j < numActiveFilters; j++) {
  71. if (td.innerText.match(activeFilters[j])) {
  72. td.parentNode.parentNode.classList.add('filtered');
  73. numFiltered++;
  74. break;
  75. }
  76. }
  77. }
  78. document.querySelector('.filter-status').textContent = document.querySelectorAll('article > h2').length - numFiltered + ' scripts (' + numFiltered + ' filtered)';
  79. }
  80.  
  81. function insertSwitches() {
  82. var span = document.createElement('span');
  83. span.className = 'filter-switches';
  84. for (var filter in filters) {
  85. if (filters.hasOwnProperty(filter)) {
  86. span.appendChild(createSwitch(filter, GM_getValue(filter, 'on') == 'on'));
  87. }
  88. }
  89. document.querySelector('.filter-status').parentNode.appendChild(span);
  90. }
  91.  
  92. function createSwitch(label, isOn) {
  93. var a = document.createElement('a');
  94. a.className = isOn ? 'filter-on' : 'filter-off';
  95. a.textContent = label;
  96. a.addEventListener('click', function(e) {
  97. if (this.className == 'filter-on') {
  98. this.className = 'filter-off';
  99. GM_setValue(this.textContent, 'off');
  100. } else {
  101. this.className = 'filter-on';
  102. GM_setValue(this.textContent, 'on');
  103. }
  104. filterScripts();
  105. e.preventDefault();
  106. }, false);
  107. return a;
  108. }
  109.  
  110. function my_GM_setValue(name, value) {
  111. localStorage.setItem(name, value);
  112. }
  113.  
  114. function my_GM_getValue(name, defaultValue) {
  115. var value;
  116. if (!(value = localStorage.getItem(name))) {
  117. return defaultValue;
  118. }
  119. return value;
  120. }
  121. })();
  122.  
  123. } else {
  124.  
  125. (function() {
  126. var filters = {
  127. 'Non-ASCII': /[^\x00-\x7F\s]+/i,
  128. '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,
  129. '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,
  130. '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
  131. };
  132. if (typeof GM_getValue == 'undefined' || (typeof GM_getValue.toString == 'function' && GM_getValue.toString().indexOf('not supported') > -1)) {
  133. GM_getValue = my_GM_getValue;
  134. GM_setValue = my_GM_setValue;
  135. }
  136. insertStyle();
  137. insertStatus();
  138. filterScripts();
  139. insertSwitches();
  140.  
  141. // 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
  142. function insertStyle() {
  143. var style = document.createElement('style');
  144. // 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 } ';
  145. 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;} ';
  146. style.type = 'text/css';
  147. document.querySelector('head').appendChild(style);
  148. }
  149.  
  150. function insertStatus() {
  151. var p = document.querySelector('#Head');
  152. if (p) {
  153. var status = document.createElement('span');
  154. status.className = 'filter-status';
  155. p.appendChild(status);
  156. }
  157. }
  158.  
  159. function filterScripts() {
  160. var activeFilters = [];
  161. for (var filter in filters) {
  162. if (filters.hasOwnProperty(filter) && GM_getValue(filter, 'on') == 'on') {
  163. activeFilters.push(filters[filter]);
  164. }
  165. }
  166. var nodes = document.querySelectorAll('.ItemDiscussion'),
  167. numActiveFilters = activeFilters.length,
  168. numFiltered = 0;
  169. for (var i = 0, numNodes = nodes.length, td = null; i < numNodes && (td = nodes[i]); i++) {
  170. td.classList.remove('filtered');
  171. for (var j = 0; j < numActiveFilters; j++) {
  172. var temp = td.children[1].firstElementChild.innerText;
  173. if(temp.match(activeFilters[j])) {
  174. td.classList.add('filtered');
  175. numFiltered++;
  176. break;
  177. }
  178. }
  179. }
  180. document.querySelector('.filter-status').innerText = (document.querySelectorAll('.ItemDiscussion').length - numFiltered) + ' discussions (' + numFiltered + ' filtered)';
  181. }
  182.  
  183. function insertSwitches() {
  184. var span = document.createElement('span');
  185. span.className = 'filter-switches';
  186. for (var filter in filters) {
  187. if (filters.hasOwnProperty(filter)) {
  188. span.appendChild(createSwitch(filter, GM_getValue(filter, 'on') == 'on'));
  189. }
  190. }
  191. document.querySelector('.filter-status').parentNode.appendChild(span);
  192. }
  193.  
  194. function createSwitch(label, isOn) {
  195. var a = document.createElement('a');
  196. a.className = isOn ? 'filter-on' : 'filter-off';
  197. a.textContent = label;
  198. a.addEventListener('click', function(e) {
  199. if (this.className == 'filter-on') {
  200. this.className = 'filter-off';
  201. GM_setValue(this.textContent, 'off');
  202. } else {
  203. this.className = 'filter-on';
  204. GM_setValue(this.textContent, 'on');
  205. }
  206. filterScripts();
  207. e.preventDefault();
  208. }, false);
  209. return a;
  210. }
  211.  
  212. function my_GM_setValue(name, value) {
  213. localStorage.setItem(name, value);
  214. }
  215.  
  216. function my_GM_getValue(name, defaultValue) {
  217. var value;
  218. if (!(value = localStorage.getItem(name))) {
  219. return defaultValue;
  220. }
  221. return value;
  222. }
  223. })();
  224.  
  225.  
  226.  
  227.  
  228. }