OpenUserJS Bullshit Filter

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

2016-09-09 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

  1. // ==UserScript==
  2. // @name OpenUserJS 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.3
  7. // @icon https://s3.amazonaws.com/uso_ss/icon/97145/large.png
  8. // @grant none
  9. // @include https://openuserjs.org/
  10. // @include https://openuserjs.org/?*p=*
  11. // @include https://openuserjs.org/?*q=*
  12. // This is an edited version of this script (http://userscripts-mirror.org/scripts/show/97145) by kuehlschrank.
  13. // Thanks a lot to kuehlschrank for making another great script.
  14. // ==/UserScript==
  15.  
  16.  
  17.  
  18. (function() {
  19. var filters = {
  20. '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,
  21. '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,
  22. 'Non-ASCII': /[^\x00-\x7F\s]+/i,
  23. '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
  24. };
  25. if (typeof GM_getValue == 'undefined' || (typeof GM_getValue.toString == 'function' && GM_getValue.toString().indexOf('not supported') > -1)) {
  26. GM_getValue = my_GM_getValue;
  27. GM_setValue = my_GM_setValue;
  28. }
  29. insertStyle();
  30. insertStatus();
  31. filterScripts();
  32. insertSwitches();
  33.  
  34. // Note: you may uncomment line 37 (and comment out line 38), in order the filtered scripts to be highlighted khaki -instead of hiding them- so that you can check which scripts have been filtered
  35. function insertStyle() {
  36. var style = document.createElement('style');
  37. // style.textContent = 'tr.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: 107px; outline: none;} .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 } ';
  38. style.textContent = 'tr.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: 107px; outline: none;} .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 } ';
  39. style.type = 'text/css';
  40. document.querySelector('head').appendChild(style);
  41. }
  42. function insertStatus() {
  43. var p = document.querySelector('.col-sm-4');
  44. if(p) {
  45. var status = document.createElement('span');
  46. status.className = 'filter-status';
  47. p.appendChild(status);
  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('.col-sm-8 tbody tr'),
  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.className = '';
  62. for(var j = 0; j < numActiveFilters; j++) {
  63. if (td.innerText.match(activeFilters[j]) ) {
  64. td.className = 'filtered';
  65. numFiltered++;
  66. break;
  67. }
  68. }
  69. }
  70. document.querySelector('.filter-status').textContent = document.querySelectorAll('.col-sm-8 tbody tr').length - numFiltered + ' scripts (' + numFiltered + ' filtered)';
  71. }
  72. function insertSwitches() {
  73. var span = document.createElement('span');
  74. span.className = 'filter-switches';
  75. for(var filter in filters) {
  76. if(filters.hasOwnProperty(filter)) {
  77. span.appendChild(createSwitch(filter, GM_getValue(filter, 'on') == 'on'));
  78. }
  79. }
  80. document.querySelector('.filter-status').parentNode.appendChild(span);
  81. }
  82. function createSwitch(label, isOn) {
  83. var a = document.createElement('a');
  84. a.className = isOn ? 'filter-on' : 'filter-off';
  85. a.textContent = label;
  86. a.addEventListener('click', function(e) {
  87. if(this.className == 'filter-on') {
  88. this.className = 'filter-off';
  89. GM_setValue(this.textContent, 'off');
  90. } else {
  91. this.className = 'filter-on';
  92. GM_setValue(this.textContent, 'on');
  93. }
  94. filterScripts();
  95. e.preventDefault();
  96. }, false);
  97. return a;
  98. }
  99. function my_GM_setValue(name, value) {
  100. localStorage.setItem(name, value);
  101. }
  102. function my_GM_getValue(name, defaultValue) {
  103. var value;
  104. if (!(value = localStorage.getItem(name))) {
  105. return defaultValue;
  106. }
  107. return value;
  108. }
  109. })();