OpenUserJS Bullshit Filter

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

Verze ze dne 07. 11. 2015. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @name OpenUserJS 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://openuserjs.org/
  9. // @include https://openuserjs.org/?*p=*
  10. // @include https://openuserjs.org/?*q=*
  11. // This is an edited version of this script (http://userscripts-mirror.org/scripts/show/97145) by kuehlschrank.
  12. // Thanks a lot to kuehlschrank for making another great script.
  13. // @namespace https://greatest.deepsurf.us/users/2160
  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|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,
  21. '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,
  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. var flag;
  34. // ADD A NEWLINE AT THE END OF EACH FILTER
  35. if (document.querySelector('.filter-status').parentNode.childNodes[5].childNodes[0].innerHTML == 'Games' ) {
  36. flag = 5; }
  37. else {flag = 9}
  38. for (i=0; i<4; i++){
  39. document.querySelector('.filter-status').parentNode.childNodes[flag].childNodes[i].innerHTML += '<br>';
  40. }
  41. // Note: you may uncomment line 45 and comment out line 46, 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 = 'tr.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 = 'tr.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. function insertStatus() {
  50. var p = document.querySelector('.col-sm-4');
  51. if(p) {
  52. var status = document.createElement('span');
  53. status.className = 'filter-status';
  54. p.appendChild(status);
  55. }
  56. p.innerHTML += '<br>'; // ADDS A NEWLINE AT THE END OF THE 'STATUS' ENTRY
  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('tr'), numActiveFilters = activeFilters.length, numFiltered = 0;
  66. for(var i = 1, numNodes = nodes.length-6, td = null; i < numNodes && (td = nodes[i]); i++) {
  67. td.className = '';
  68. for(var j = 0; j < numActiveFilters; j++) {
  69. if(typeof (td.childNodes[1].childNodes[9]) !== "undefined"){ // Check whether the current script disctription" element is not undefined, i.e. it exists
  70. if(td.childNodes[1].childNodes[9].textContent.match(activeFilters[j]) ) {
  71. td.className = 'filtered';
  72. numFiltered++;
  73. break;
  74. }
  75. }
  76. }
  77. }
  78. document.querySelector('.filter-status').textContent = document.querySelectorAll('tr').length-numFiltered-6 + ' scripts (' + numFiltered + ' filtered)';
  79. }
  80. function insertSwitches() {
  81. var span = document.createElement('span');
  82. span.className = 'filter-switches';
  83. for(var filter in filters) {
  84. if(filters.hasOwnProperty(filter)) {
  85. span.appendChild(createSwitch(filter, GM_getValue(filter, 'on') == 'on'));
  86. }
  87. }
  88. document.querySelector('.filter-status').parentNode.appendChild(span);
  89. }
  90. function createSwitch(label, isOn) {
  91. var a = document.createElement('a');
  92. a.className = isOn ? 'filter-on' : 'filter-off';
  93. a.textContent = label;
  94. a.addEventListener('click', function(e) {
  95. if(this.className == 'filter-on') {
  96. this.className = 'filter-off';
  97. GM_setValue(this.textContent, 'off');
  98. } else {
  99. this.className = 'filter-on';
  100. GM_setValue(this.textContent, 'on');
  101. }
  102. filterScripts();
  103. e.preventDefault();
  104. }, false);
  105. return a;
  106. }
  107. function my_GM_setValue(name, value) {
  108. localStorage.setItem(name, value);
  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. })();