OpenUserJS Bullshit Filter

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

当前为 2018-09-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name OpenUserJS Bullshit Filter
  3. // @namespace darkred
  4. // @version 2018.9.12.3
  5. // @description Hides scripts for popular browser games and social networks as well as scripts that use "foreign" characters in descriptions.
  6. // @author kuehlschrank, darkred
  7. // @license MIT
  8. // @include https://openuserjs.org/
  9. // @include https://openuserjs.org/?*p=*
  10. // @include https://openuserjs.org/?*q=*
  11. // @include https://openuserjs.org/?orderBy=*
  12. // @include https://openuserjs.org/group/*
  13. // @include https://openuserjs.org/?library=true*
  14. // @include https://openuserjs.org/users/*/scripts
  15. // @grant none
  16. // @icon https://raw.githubusercontent.com/darkred/Userscripts/master/OpenUserJS_Bullshit_Filter/large.png
  17. // This is an edited version of this script (http://userscripts-mirror.org/scripts/show/97145) by kuehlschrank.
  18. // Thanks a lot to kuehlschrank for making another great script.
  19. // ==/UserScript==
  20.  
  21.  
  22.  
  23. (function() {
  24. var filters = {
  25. '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/iu,
  26. '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/iu,
  27. 'Non-ASCII': /[^\x00-\x7F\s]+/iu,
  28. '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|theme|(night|dark) ?(mode)?/iu
  29. };
  30. if (typeof GM_getValue === 'undefined' || (typeof GM_getValue.toString === 'function' && GM_getValue.toString().indexOf('not supported') > -1)) {
  31. GM_getValue = my_GM_getValue;
  32. GM_setValue = my_GM_setValue;
  33. }
  34. insertStyle();
  35. insertStatus();
  36. filterScripts();
  37. insertSwitches();
  38.  
  39. // 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
  40. function insertStyle() {
  41. var style = document.createElement('style');
  42. // 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: 125px; 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 } ';
  43. 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: 125px; 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 } ';
  44. style.type = 'text/css';
  45. document.querySelector('head').appendChild(style);
  46. }
  47. function insertStatus() {
  48. var p = document.querySelector('.col-sm-4');
  49. if(p) {
  50. var status = document.createElement('span');
  51. status.className = 'filter-status';
  52. p.appendChild(status);
  53. }
  54. }
  55. function filterScripts() {
  56. var activeFilters = [];
  57. for(var filter in filters) {
  58. if(filters.hasOwnProperty(filter) && GM_getValue(filter, 'on') === 'on') {
  59. activeFilters.push(filters[filter]);
  60. }
  61. }
  62. var nodes = document.querySelectorAll('.col-sm-8 tbody tr'),
  63. numActiveFilters = activeFilters.length,
  64. numFiltered = 0;
  65. for (var i = 0, numNodes = nodes.length, td = null; i < numNodes && (td = nodes[i]); i++) {
  66. td.className = '';
  67. for(var j = 0; j < numActiveFilters; j++) {
  68. if (td.innerText.match(activeFilters[j]) ) {
  69. td.className = 'filtered';
  70. numFiltered++;
  71. break;
  72. }
  73. }
  74. }
  75. document.querySelector('.filter-status').textContent = document.querySelectorAll('.col-sm-8 tbody tr').length - numFiltered + ' scripts (' + numFiltered + ' filtered)';
  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. function createSwitch(label, isOn) {
  88. var a = document.createElement('a');
  89. a.className = isOn ? 'filter-on' : 'filter-off';
  90. a.textContent = label;
  91. a.addEventListener('click', function(e) {
  92. if(this.className === 'filter-on') {
  93. this.className = 'filter-off';
  94. GM_setValue(this.textContent, 'off');
  95. } else {
  96. this.className = 'filter-on';
  97. GM_setValue(this.textContent, 'on');
  98. }
  99. filterScripts();
  100. e.preventDefault();
  101. }, false);
  102. return a;
  103. }
  104. function my_GM_setValue(name, value) {
  105. localStorage.setItem(name, value);
  106. }
  107. function my_GM_getValue(name, defaultValue) {
  108. var value;
  109. if (!(value = localStorage.getItem(name))) {
  110. return defaultValue;
  111. }
  112. return value;
  113. }
  114. })();