OpenUserJS Bullshit Filter

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

As of 2019-02-01. See the latest version.

  1. // ==UserScript==
  2. // @name OpenUserJS Bullshit Filter
  3. // @namespace darkred
  4. // @version 2019.2.2
  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, valacar
  7. // @license MIT
  8. // @include /^https:\/\/openuserjs\.org\/((\?(q|p|orderBy|library)=|group\/|users\/.*\/scripts).*)?$/
  9. // @grant none
  10. // @icon https://raw.githubusercontent.com/darkred/Userscripts/master/OpenUserJS_Bullshit_Filter/large.png
  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. // Thanks a lot to valacar for the refactoring.
  14. // ==/UserScript==
  15.  
  16.  
  17. (function() {
  18.  
  19. const DEBUGGING = 0;
  20.  
  21. const filters = {
  22. 'Non-ASCII': /[^\x00-\xBF\s]+/i,
  23. 'Games': /\w+\.io|Aimbot|AntiGame|Agar|agar\.io|alis\.io|angel\.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|chopcoin\.io|Comunio|Conquer\s*Club|CosmoPulse|cursors\.io|Dark\s*Orbit|Dead\s*Frontier|Diep\.io|\bDOA\b|doblons\.io|DotD|Dossergame|Dragons\s*of\s*Atlantis|driftin\.io|Dugout|\bDS[a-z]+\n|elites\.io|Empire\s*Board|eRep(ublik)?|Epicmafia|Epic.*War|ExoPlanet|Falcon Tools|Feuerwache|Farming|FarmVille|Fightinfo|Frontier\s*Ville|Ghost\s*Trapper|Gladiatus|Goalline|Gondal|gota\.io|Grepolis|Hobopolis|\bhwm(\b|_)|Ikariam|\bIT2\b|Jellyneo|Kapi\s*Hospital|Kings\s*Age|Kingdoms?\s*of|knastv(o|oe)gel|Knight\s*Fight|\b(Power)?KoC(Atta?ck)?\b|\bKOL\b|Kongregate|Last\s*Emperor|Legends?\s*of|Light\s*Rising|lite\.ext\.io|Lockerz|\bLoU\b|Mafia\s*(Wars|Mofo)|Menelgame|Mob\s*Wars|Mouse\s*Hunt|Molehill\s*Empire|NeoQuest|MyFreeFarm|narwhale\.io|Neopets|Nemexia|\bOGame\b|Ogar(io)?|Pardus|Pennergame|Pigskin\s*Empire|PlayerScripts|pokeradar\.io|Popmundo|Po?we?r\s*(Bot|Tools)|PsicoTSI|Ravenwood|Schulterglatze|slither\.io|slitherplus\.io|slitheriogameplay|SpaceWars|splix\.io|\bSW_[a-z]+\n|\bSnP\b|The\s*Crims|The\s*West|torto\.io|Travian|Treasure\s*Isl(and|e)|Tribal\s*Wars|TW.?PRO|Vampire\s*Wars|vertix\.io|War\s*of\s*Ninja|World\s*of\s*Tanks|West\s*Wars|wings\.io|\bWoD\b|World\s*of\s*Dungeons|wtf\s*battles|Wurzelimperium/iu,
  24. '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,
  25. '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
  26. };
  27.  
  28. const commonCss = `
  29. .filter-status {
  30. margin-left: 6px;
  31. }
  32.  
  33. .filter-switches {
  34. display: none;
  35. }
  36.  
  37. :hover>.filter-switches {
  38. display: block;
  39. }
  40.  
  41. .filter-on,
  42. .filter-off {
  43. display: block;
  44. width: 125px;
  45. }
  46.  
  47. .filter-switches a {
  48. text-decoration: none;
  49. color: inherit;
  50. cursor: pointer;
  51. }
  52.  
  53. .filter-switches a {
  54. margin-left: 8px;
  55. padding: 0 4px;
  56. }
  57.  
  58. a.filter-on {
  59. background-color: #ffcccc;
  60. color: #333333;
  61. text-decoration: line-through;
  62. }
  63.  
  64. a.filter-off {
  65. background-color: #ccffcc;
  66. color: #333333
  67. }
  68. `;
  69.  
  70. // const isOnForum = window.location.href.includes('forum');
  71.  
  72. const site = {};
  73.  
  74.  
  75.  
  76. // if (isOnForum) {
  77. // // site.css = '.ItemDiscussion.filtered { display: none; } .filter-on, .filter-off { color: black; } ' + commonCss;
  78. // site.css = '.tr-link.filtered { display: none; } ' + commonCss;
  79. // site.cssDebug = '.tr-link.filtered { background-color: khaki; } ' + commonCss;
  80. // // site.filterStatusLocation = '#Head';
  81. // site.filterStatusLocation = '.col-md-2';
  82. // site.itemsToCheck = '.tr-link';
  83. // site.itemType = 'discussions';
  84. // site.removeFilter = function(el) {
  85. // el.classList.remove('filtered');
  86. // };
  87. // site.applyFilter = function(el, activeFilter) {
  88. // let textToFilter = el.firstElementChild.firstElementChild.innerText;
  89. // if (textToFilter.match(activeFilter) ) {
  90. // el.classList.add('filtered');
  91. // return true;
  92. // }
  93. // return false;
  94. // };
  95. // } else {
  96.  
  97. site.css = 'tr.filtered { display: none; } ' + commonCss;
  98. site.cssDebug = 'tr.filtered { background-color: khaki; } ' + commonCss;
  99. site.filterStatusLocation = '.col-sm-4';
  100. site.itemsToCheck = '.col-sm-8 tbody tr';
  101. site.itemType = 'scripts';
  102. site.removeFilter = function(el) {
  103. el.classList.remove('filtered');
  104. };
  105. site.applyFilter = function(el, activeFilter) {
  106. // if (el.innerText.match(activeFilter)) {
  107. let textToFilter = el.firstElementChild.querySelector('a.tr-link-a').innerText + ' ' + el.firstElementChild.lastElementChild.innerText ; // Script title + description
  108. if (textToFilter.match(activeFilter) ) {
  109.  
  110. el.classList.add('filtered');
  111. return true;
  112. }
  113. return false;
  114. };
  115. // }
  116.  
  117. insertStyle();
  118. insertStatus();
  119. filterScripts();
  120. insertSwitches();
  121.  
  122. function insertStyle() {
  123. const style = document.createElement('style');
  124. style.textContent = DEBUGGING ? site.cssDebug : site.css;
  125. style.type = 'text/css';
  126. document.head.appendChild(style);
  127. }
  128.  
  129. function insertStatus() {
  130. const p = document.querySelector(site.filterStatusLocation);
  131. if (p) {
  132. const status = document.createElement('span');
  133. status.className = 'filter-status';
  134. p.appendChild(status);
  135. }
  136. }
  137.  
  138.  
  139.  
  140. function filterScripts() {
  141. const activeFilters = [];
  142. for (let filterType of Object.keys(filters)) {
  143. if (configGetValue(filterType, 'on') === 'on') {
  144. activeFilters.push(filters[filterType]);
  145. }
  146. }
  147. const nodes = document.querySelectorAll(site.itemsToCheck);
  148. let numFiltered = 0;
  149. for (let node of nodes) {
  150. site.removeFilter(node);
  151. for (let activeFilter of activeFilters) {
  152. let filtered = site.applyFilter(node, activeFilter);
  153. if (filtered) {
  154. numFiltered++;
  155. break;
  156. }
  157. }
  158. }
  159. const filterStatus = document.querySelector('.filter-status');
  160. if (filterStatus) {
  161. const numUnfiltered = document.querySelectorAll(site.itemsToCheck).length - numFiltered;
  162. filterStatus.textContent = `${numUnfiltered} ${site.itemType} (${numFiltered} filtered)`;
  163. }
  164. }
  165.  
  166. function insertSwitches() {
  167. const span = document.createElement('span');
  168. span.className = 'filter-switches';
  169. for (let filterType of Object.keys(filters)) {
  170. span.appendChild(createSwitch(filterType, configGetValue(filterType, 'on') === 'on'));
  171. }
  172. const filterStatus = document.querySelector('.filter-status');
  173. if (filterStatus) {
  174. filterStatus.parentNode.appendChild(span);
  175. }
  176. }
  177.  
  178. function createSwitch(label, isOn) {
  179. const a = document.createElement('a');
  180. a.className = isOn ? 'filter-on' : 'filter-off';
  181. a.textContent = label;
  182. a.addEventListener('click', function(e) {
  183. if (this.className === 'filter-on') {
  184. this.className = 'filter-off';
  185. configSetValue(this.textContent, 'off');
  186. } else {
  187. this.className = 'filter-on';
  188. configSetValue(this.textContent, 'on');
  189. }
  190. filterScripts();
  191. e.preventDefault();
  192. }, false);
  193. return a;
  194. }
  195.  
  196. function configSetValue(name, value) {
  197. localStorage.setItem(name, value);
  198. }
  199.  
  200. function configGetValue(name, defaultValue) {
  201. const value = localStorage.getItem(name);
  202. return value ? value : defaultValue;
  203. }
  204.  
  205. })();