GreasyFork Bullshit Filter

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

当前为 2016-08-30 提交的版本,查看 最新版本

  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 1.2.2
  7. // @icon https://s3.amazonaws.com/uso_ss/icon/97145/large.png
  8. // @grant none
  9. // @include https://greasyfork.org/*/scripts*
  10. // This is an edited version of this script (http://userscripts-mirror.org/scripts/show/97145) by kuehlschrank.
  11. // Thanks a lot to kuehlschrank for making another great script.
  12. // ==/UserScript==
  13.  
  14.  
  15.  
  16. (function() {
  17. var filters = {
  18. 'Games': /AntiGame|Agar|agar.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|Comunio|Conquer\s*Club|CosmoPulse|Dark\s*Orbit|Dead\s*Frontier|Diep\.io|\bDOA\b|Dossergame|Dragons\s*of\s*Atlantis|Dugout|\bDS[a-z]+\n|Empire\s*Board|eRep(ublik)?|Epic.*War|ExoPlanet|Falcon Tools|Feuerwache|Farming|FarmVille|Fightinfo|Frontier\s*Ville|Ghost\s*Trapper|Gladiatus|Goalline|Gondal|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|Lockerz|\bLoU\b|Mafia\s*(Wars|Mofo)|Menelgame|Mob\s*Wars|Mouse\s*Hunt|Molehill\s*Empire|NeoQuest|MyFreeFarm|Neopets|Nemexia|\bOGame\b|Ogar(io)?|Pardus|Pennergame|Pigskin\s*Empire|PlayerScripts|Popmundo|Po?we?r\s*(Bot|Tools)|PsicoTSI|Ravenwood|Schulterglatze|slither\.io|SpaceWars|\bSW_[a-z]+\n|\bSnP\b|The\s*Crims|The\s*West|Travian|Treasure\s*Isl(and|e)|Tribal\s*Wars|TW.?PRO|Vampire\s*Wars|War\s*of\s*Ninja|West\s*Wars|\bWoD\b|World\s*of\s*Dungeons|wtf\s*battles|Wurzelimperium/i,
  19. 'Social Networks': /Face\s*book|Google(\+| Plus)|\bHabbo|Kaskus|\bLepra|Leprosorium|MySpace|meinVZ|odnoklassniki|Одноклассники|Orkut|sch(ue|ü)ler(VZ|\.cc)?|studiVZ|Unfriend|Valenth|vkontakte|ВКонтакте|Qzone|Twitter|TweetDeck/i,
  20. 'Non-ASCII': /[^\x00-\x7F\s]+/i,
  21. '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
  22. };
  23. if (typeof GM_getValue == 'undefined' || (typeof GM_getValue.toString == 'function' && GM_getValue.toString().indexOf('not supported') > -1)) {
  24. GM_getValue = my_GM_getValue;
  25. GM_setValue = my_GM_setValue;
  26. }
  27. insertStyle();
  28. insertStatus();
  29. filterScripts();
  30. insertSwitches();
  31.  
  32. // 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
  33. function insertStyle() {
  34. var style = document.createElement('style');
  35. // 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 } ';
  36. 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 } ';
  37. style.type = 'text/css';
  38. document.querySelector('head').appendChild(style);
  39. }
  40.  
  41. function insertStatus() {
  42. var p = document.querySelector('#script-list-option-groups');
  43. if (p) {
  44. var status = document.createElement('span');
  45. status.className = 'filter-status';
  46. p.appendChild(status);
  47. }
  48. }
  49.  
  50. function filterScripts() {
  51. var activeFilters = [];
  52. for (var filter in filters) {
  53. if (filters.hasOwnProperty(filter) && GM_getValue(filter, 'on') == 'on') {
  54. activeFilters.push(filters[filter]);
  55. }
  56. }
  57. var nodes = document.querySelectorAll('article > h2'),
  58. numActiveFilters = activeFilters.length,
  59. numFiltered = 0;
  60. for (var i = 0, numNodes = nodes.length, td = null; i < numNodes && (td = nodes[i]); i++) {
  61. td.parentNode.className = '';
  62. for (var j = 0; j < numActiveFilters; j++) {
  63. if (td.textContent.match(activeFilters[j])) {
  64. td.parentNode.className = 'filtered';
  65. numFiltered++;
  66. break;
  67. }
  68. }
  69. }
  70. document.querySelector('.filter-status').textContent = document.querySelectorAll('article > h2').length - numFiltered + ' scripts (' + numFiltered + ' filtered)';
  71. }
  72.  
  73. function insertSwitches() {
  74. var span = document.createElement('span');
  75. span.className = 'filter-switches';
  76. for (var filter in filters) {
  77. if (filters.hasOwnProperty(filter)) {
  78. span.appendChild(createSwitch(filter, GM_getValue(filter, 'on') == 'on'));
  79. }
  80. }
  81. document.querySelector('.filter-status').parentNode.appendChild(span);
  82. }
  83.  
  84. function createSwitch(label, isOn) {
  85. var a = document.createElement('a');
  86. a.className = isOn ? 'filter-on' : 'filter-off';
  87. a.textContent = label;
  88. a.addEventListener('click', function(e) {
  89. if (this.className == 'filter-on') {
  90. this.className = 'filter-off';
  91. GM_setValue(this.textContent, 'off');
  92. } else {
  93. this.className = 'filter-on';
  94. GM_setValue(this.textContent, 'on');
  95. }
  96. filterScripts();
  97. e.preventDefault();
  98. }, false);
  99. return a;
  100. }
  101.  
  102. function my_GM_setValue(name, value) {
  103. localStorage.setItem(name, value);
  104. }
  105.  
  106. function my_GM_getValue(name, defaultValue) {
  107. var value;
  108. if (!(value = localStorage.getItem(name))) {
  109. return defaultValue;
  110. }
  111. return value;
  112. }
  113. })();