GreasyFork Bullshit Filter

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

当前为 2015-11-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GreasyFork Bullshit Filter
  3. // @author darkred
  4. // @description Hides scripts for popular browser games and social networks as well as scripts that use "foreign" characters in descriptions.
  5. // @version 1.1
  6. // @icon https://s3.amazonaws.com/uso_ss/icon/97145/large.png
  7. // @grant none
  8. // @include https://greasyfork.org/*/scripts*
  9. // This is an edited version of this script (http://userscripts-mirror.org/scripts/show/97145) by kuehlschrank.
  10. // Thanks a lot to kuehlschrank for making another great script.
  11. // @namespace rikkie
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. var filters = {
  16. '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|Bots4|Brawler|\bBvS\b|Business\s*Tycoon|Castle\s*Age|City\s*Ville|Comunio|Conquer\s*Club|CosmoPulse|Dark\s*Orbit|Dead\s*Frontier|\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|Pardus|Pennergame|Pigskin\s*Empire|PlayerScripts|Popmundo|Po?we?r\s*(Bot|Tools)|PsicoTSI|Ravenwood|Schulterglatze|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,
  17. '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/i,
  18. 'Non-ASCII': /[^\x00-\x7F\s]+/i,
  19. '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
  20. };
  21. if (typeof GM_getValue == 'undefined' || (typeof GM_getValue.toString == 'function' && GM_getValue.toString().indexOf('not supported') > -1)) {
  22. GM_getValue = my_GM_getValue;
  23. GM_setValue = my_GM_setValue;
  24. }
  25. insertStyle();
  26. insertStatus();
  27. filterScripts();
  28. insertSwitches();
  29.  
  30. var flag;
  31. // ADD A NEWLINE AT THE END OF EACH FILTER
  32. if (document.querySelector('.filter-status').parentNode.childNodes[5].childNodes[0].innerHTML == 'Games') {
  33. flag = 5;
  34. } else {
  35. flag = 9;
  36. }
  37. for (i = 0; i < 4; i++) {
  38. document.querySelector('.filter-status').parentNode.childNodes[flag].childNodes[i].innerHTML += '<br>';
  39. }
  40.  
  41. // Note: you may uncomment line 41 and comment out line 42, in order the filtered scripts to be highlighted yellow -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 = 'article.filtered { background-color:yellow; !important; } .filter-status { margin-left: 6px; } .filter-switches { display:none; } *:hover > .filter-switches { display:inline; } .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 } a.filter-off { background-color:#ccffcc; color:#333333 } ';
  45. style.textContent = 'article.filtered { display:none; !important; } .filter-status { margin-left: 6px; } .filter-switches { display:none; } *:hover > .filter-switches { display:inline; } .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 } 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. p.innerHTML += '<br>'; // ADDS A NEWLINE AT THE END OF THE 'STATUS' ENTRY
  58. }
  59.  
  60. function filterScripts() {
  61. var activeFilters = [];
  62. for (var filter in filters) {
  63. if (filters.hasOwnProperty(filter) && GM_getValue(filter, 'on') == 'on') {
  64. activeFilters.push(filters[filter]);
  65. }
  66. }
  67. var nodes = document.querySelectorAll('article > h2'),
  68. numActiveFilters = activeFilters.length,
  69. numFiltered = 0;
  70. for (var i = 0, numNodes = nodes.length, td = null; i < numNodes && (td = nodes[i]); i++) {
  71. td.parentNode.className = '';
  72. for (var j = 0; j < numActiveFilters; j++) {
  73. if (td.textContent.match(activeFilters[j])) {
  74. td.parentNode.className = 'filtered';
  75. numFiltered++;
  76. break;
  77. }
  78. }
  79. }
  80. document.querySelector('.filter-status').textContent = document.querySelectorAll('article > h2').length - numFiltered + ' scripts (' + numFiltered + ' filtered)';
  81. }
  82.  
  83. function insertSwitches() {
  84. var span = document.createElement('span');
  85. span.className = 'filter-switches';
  86. for (var filter in filters) {
  87. if (filters.hasOwnProperty(filter)) {
  88. span.appendChild(createSwitch(filter, GM_getValue(filter, 'on') == 'on'));
  89. }
  90. }
  91. document.querySelector('.filter-status').parentNode.appendChild(span);
  92. }
  93.  
  94. function createSwitch(label, isOn) {
  95. var a = document.createElement('a');
  96. a.className = isOn ? 'filter-on' : 'filter-off';
  97. a.textContent = label;
  98. a.addEventListener('click', function(e) {
  99. if (this.className == 'filter-on') {
  100. this.className = 'filter-off';
  101. GM_setValue(this.textContent, 'off');
  102. } else {
  103. this.className = 'filter-on';
  104. GM_setValue(this.textContent, 'on');
  105. }
  106. filterScripts();
  107. e.preventDefault();
  108. }, false);
  109. return a;
  110. }
  111.  
  112. function my_GM_setValue(name, value) {
  113. localStorage.setItem(name, value);
  114. }
  115.  
  116. function my_GM_getValue(name, defaultValue) {
  117. var value;
  118. if (!(value = localStorage.getItem(name))) {
  119. return defaultValue;
  120. }
  121. return value;
  122. }
  123. })();