GreasyFork Bullshit Filter

Hides scripts for popular browser games and social networks as well as scripts that use "foreign" characters in descriptions.

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

  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.
  6. // @version 2016.11.12
  7. // @icon https://s3.amazonaws.com/uso_ss/icon/97145/large.png
  8. // @grant none
  9. // @include https://greasyfork.org/*/scripts
  10. // @include https://greasyfork.org/*/scripts/
  11. // @include https://greasyfork.org/*/scripts?page=*
  12. // @include https://greasyfork.org/*/scripts?per_page=*
  13. // @include https://greasyfork.org/*/scripts/search?*
  14. // This is an edited version of this script (http://userscripts-mirror.org/scripts/show/97145) by kuehlschrank.
  15. // Thanks a lot to kuehlschrank for making another great script.
  16. // ==/UserScript==
  17.  
  18.  
  19.  
  20. (function() {
  21. var filters = {
  22. '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,
  23. '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,
  24. 'Non-ASCII': /[^\x00-\x7F\s]+/i,
  25. '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
  26. };
  27. if (typeof GM_getValue == 'undefined' || (typeof GM_getValue.toString == 'function' && GM_getValue.toString().indexOf('not supported') > -1)) {
  28. GM_getValue = my_GM_getValue;
  29. GM_setValue = my_GM_setValue;
  30. }
  31. insertStyle();
  32. insertStatus();
  33. filterScripts();
  34. insertSwitches();
  35.  
  36. // 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
  37. function insertStyle() {
  38. var style = document.createElement('style');
  39. // style.textContent = 'article.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 } ';
  40. style.textContent = 'article.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 } ';
  41. style.type = 'text/css';
  42. document.querySelector('head').appendChild(style);
  43. }
  44.  
  45. function insertStatus() {
  46. var p = document.querySelector('#script-list-option-groups');
  47. if (p) {
  48. var status = document.createElement('span');
  49. status.className = 'filter-status';
  50. p.appendChild(status);
  51. }
  52. }
  53.  
  54. function filterScripts() {
  55. var activeFilters = [];
  56. for (var filter in filters) {
  57. if (filters.hasOwnProperty(filter) && GM_getValue(filter, 'on') == 'on') {
  58. activeFilters.push(filters[filter]);
  59. }
  60. }
  61. var nodes = document.querySelectorAll('article > h2'),
  62. numActiveFilters = activeFilters.length,
  63. numFiltered = 0;
  64. for (var i = 0, numNodes = nodes.length, td = null; i < numNodes && (td = nodes[i]); i++) {
  65. td.parentNode.className = '';
  66. for (var j = 0; j < numActiveFilters; j++) {
  67. if (td.innerText.match(activeFilters[j])) {
  68. td.parentNode.className = 'filtered';
  69. numFiltered++;
  70. break;
  71. }
  72. }
  73. }
  74. document.querySelector('.filter-status').textContent = document.querySelectorAll('article > h2').length - numFiltered + ' scripts (' + numFiltered + ' filtered)';
  75. }
  76.  
  77. function insertSwitches() {
  78. var span = document.createElement('span');
  79. span.className = 'filter-switches';
  80. for (var filter in filters) {
  81. if (filters.hasOwnProperty(filter)) {
  82. span.appendChild(createSwitch(filter, GM_getValue(filter, 'on') == 'on'));
  83. }
  84. }
  85. document.querySelector('.filter-status').parentNode.appendChild(span);
  86. }
  87.  
  88. function createSwitch(label, isOn) {
  89. var a = document.createElement('a');
  90. a.className = isOn ? 'filter-on' : 'filter-off';
  91. a.textContent = label;
  92. a.addEventListener('click', function(e) {
  93. if (this.className == 'filter-on') {
  94. this.className = 'filter-off';
  95. GM_setValue(this.textContent, 'off');
  96. } else {
  97. this.className = 'filter-on';
  98. GM_setValue(this.textContent, 'on');
  99. }
  100. filterScripts();
  101. e.preventDefault();
  102. }, false);
  103. return a;
  104. }
  105.  
  106. function my_GM_setValue(name, value) {
  107. localStorage.setItem(name, value);
  108. }
  109.  
  110. function my_GM_getValue(name, defaultValue) {
  111. var value;
  112. if (!(value = localStorage.getItem(name))) {
  113. return defaultValue;
  114. }
  115. return value;
  116. }
  117. })();