OpenUserJS Bullshit Filter

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

当前为 2019-12-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name OpenUserJS Bullshit Filter
  3. // @namespace darkred
  4. // @version 2019.12.5
  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, Graphen
  7. // @license MIT
  8. // @include /^https:\/\/openuserjs\.org\/((\?(q|p|orderBy|library)=|group\/|users\/.*\/scripts).*)?$/
  9. // @include /^http:\/\/localhost:8080\/((\?(q|p|orderBy|library)=|group\/|users\/.*\/scripts).*)?$/
  10. // @grant none
  11. // @icon https://raw.githubusercontent.com/darkred/Userscripts/master/OpenUserJS_Bullshit_Filter/large.png
  12. // This is a modified version of this script (http://userscripts-mirror.org/scripts/show/97145) by kuehlschrank.
  13. // Thanks a lot to:
  14. // - kuehlschrank for making another great script,
  15. // - valacar for the refactoring,
  16. // - Graphen for the 'Non-Latin' regex.
  17. // ==/UserScript==
  18.  
  19.  
  20. (function() {
  21.  
  22. const DEBUGGING = 0;
  23.  
  24. const filters = {
  25. 'Non-ASCII': /[^\x00-\x7F\s]+/,
  26. 'Non-Latin': /[^\u0000-\u024F\u2000-\u214F\s]+/,
  27. 'Games': /Aimbot|AntiGame|Agar|agar\.io|alis\.io|angel\.io|ExtencionRipXChetoMalo|AposBot|DFxLite|ZTx-Lite|AposFeedingBot|AposLoader|Balz|Blah Blah|Orc Clan Script|Astro\s*Empires|^\s*Attack|^\s*Battle|BiteFight|Blood\s*Wars|Bloble|Bonk|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|Krunker|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|MooMoo|MyFreeFarm|narwhale\.io|Neopets|NeoQuest|Nemexia|\bOGame\b|Ogar(io)?|Pardus|Pennergame|Pigskin\s*Empire|PlayerScripts|pokeradar\.io|Popmundo|Po?we?r\s*(Bot|Tools)|PsicoTSI|Ravenwood|Schulterglatze|Skribbl|slither\.io|slitherplus\.io|slitheriogameplay|SpaceWars|splix\.io|Survivio|\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|Yohoho|Zombs/iu,
  28. '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,
  29. 'Clutter': /^\s*(.{1,3})\1+\n|^\s*(.+?)\n+\2\n*$|^\s*.{1,5}\n|do\s*n('|o)?t (install|download)|nicht installieren|(just )?(\ban? |\b)test(ing|s|\d|\b)|^\s*.{0,4}test.{0,4}\n|\ntest(ing)?\s*|^\s*(\{@|Smolka|Hacks)|\[\d{4,5}\]|free\s*download|theme|(night|dark) ?(mode)?/iu
  30. };
  31.  
  32. const commonCss = `
  33. .filter-status {
  34. margin-left: 6px;
  35. }
  36.  
  37. .filter-switches {
  38. display: none;
  39. }
  40.  
  41. :hover>.filter-switches {
  42. display: block;
  43. }
  44.  
  45. .filter-on,
  46. .filter-off {
  47. display: block;
  48. width: 125px;
  49. }
  50.  
  51. .filter-switches a {
  52. text-decoration: none;
  53. color: inherit;
  54. cursor: pointer;
  55. }
  56.  
  57. .filter-switches a {
  58. margin-left: 8px;
  59. padding: 0 4px;
  60. }
  61.  
  62. a.filter-on {
  63. background-color: #ffcccc;
  64. color: #333333;
  65. text-decoration: line-through;
  66. }
  67.  
  68. a.filter-off {
  69. background-color: #ccffcc;
  70. color: #333333
  71. }
  72. `;
  73.  
  74. // const isOnForum = window.location.href.includes('forum');
  75.  
  76. const site = {};
  77.  
  78.  
  79.  
  80. // if (isOnForum) {
  81. // // site.css = '.ItemDiscussion.filtered { display: none; } .filter-on, .filter-off { color: black; } ' + commonCss;
  82. // site.css = '.tr-link.filtered { display: none; } ' + commonCss;
  83. // site.cssDebug = '.tr-link.filtered { background-color: khaki; } ' + commonCss;
  84. // // site.filterStatusLocation = '#Head';
  85. // site.filterStatusLocation = '.col-md-2';
  86. // site.itemsToCheck = '.tr-link';
  87. // site.itemType = 'discussions';
  88. // site.removeFilter = function(el) {
  89. // el.classList.remove('filtered');
  90. // };
  91. // site.applyFilter = function(el, activeFilter) {
  92. // let textToFilter = el.firstElementChild.firstElementChild.innerText;
  93. // if (textToFilter.match(activeFilter) ) {
  94. // el.classList.add('filtered');
  95. // return true;
  96. // }
  97. // return false;
  98. // };
  99. // } else {
  100.  
  101. site.css = 'tr.filtered { display: none; } ' + commonCss;
  102. site.cssDebug = 'tr.filtered { background-color: khaki; } ' + commonCss;
  103. site.filterStatusLocation = '.col-sm-4';
  104. site.itemsToCheck = '.col-sm-8 tbody tr';
  105. site.itemType = 'scripts';
  106. site.removeFilter = function(el) {
  107. el.classList.remove('filtered');
  108. };
  109. site.applyFilter = function(el, activeFilter) {
  110. // if (el.innerText.match(activeFilter)) {
  111. let textToFilter = el.firstElementChild.querySelector('a.tr-link-a').innerText + ' ' + el.firstElementChild.lastElementChild.innerText ; // Script title + description
  112. if (textToFilter.match(activeFilter) ) {
  113.  
  114. el.classList.add('filtered');
  115. return true;
  116. }
  117. return false;
  118. };
  119. // }
  120.  
  121. insertStyle();
  122. insertStatus();
  123. filterScripts();
  124. insertSwitches();
  125.  
  126. function insertStyle() {
  127. const style = document.createElement('style');
  128. style.textContent = DEBUGGING ? site.cssDebug : site.css;
  129. style.type = 'text/css';
  130. document.head.appendChild(style);
  131. }
  132.  
  133. function insertStatus() {
  134. const p = document.querySelector(site.filterStatusLocation);
  135. if (p) {
  136. const status = document.createElement('span');
  137. status.className = 'filter-status';
  138. p.appendChild(status);
  139. }
  140. }
  141.  
  142.  
  143.  
  144. function filterScripts() {
  145. const activeFilters = [];
  146. for (let filterType of Object.keys(filters)) {
  147. if (configGetValue(filterType, 'on') === 'on') {
  148. activeFilters.push(filters[filterType]);
  149. }
  150. }
  151. const nodes = document.querySelectorAll(site.itemsToCheck);
  152. let numFiltered = 0;
  153. for (let node of nodes) {
  154. site.removeFilter(node);
  155. for (let activeFilter of activeFilters) {
  156. let filtered = site.applyFilter(node, activeFilter);
  157. if (filtered) {
  158. numFiltered++;
  159. break;
  160. }
  161. }
  162. }
  163. const filterStatus = document.querySelector('.filter-status');
  164. if (filterStatus) {
  165. const numUnfiltered = document.querySelectorAll(site.itemsToCheck).length - numFiltered;
  166. filterStatus.textContent = `${numUnfiltered} ${site.itemType} (${numFiltered} filtered)`;
  167. }
  168. }
  169.  
  170. function insertSwitches() {
  171. const span = document.createElement('span');
  172. span.className = 'filter-switches';
  173. for (let filterType of Object.keys(filters)) {
  174. span.appendChild(createSwitch(filterType, configGetValue(filterType, 'on') === 'on'));
  175. }
  176. const filterStatus = document.querySelector('.filter-status');
  177. if (filterStatus) {
  178. filterStatus.parentNode.appendChild(span);
  179. }
  180. }
  181.  
  182. function createSwitch(label, isOn) {
  183. const a = document.createElement('a');
  184. a.className = isOn ? 'filter-on' : 'filter-off';
  185. a.textContent = label;
  186. a.addEventListener('click', function(e) {
  187. if (this.className === 'filter-on') {
  188. this.className = 'filter-off';
  189. configSetValue(this.textContent, 'off');
  190. } else {
  191. this.className = 'filter-on';
  192. configSetValue(this.textContent, 'on');
  193. }
  194. filterScripts();
  195. e.preventDefault();
  196. }, false);
  197. return a;
  198. }
  199.  
  200. function configSetValue(name, value) {
  201. localStorage.setItem(name, value);
  202. }
  203.  
  204. function configGetValue(name, defaultValue) {
  205. const value = localStorage.getItem(name);
  206. return value ? value : defaultValue;
  207. }
  208.  
  209. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址