Greasy Fork is available in English.

greasyfork.org langfilter

filters out scripts and posts containing non-latin letters in title

  1. // ==UserScript==
  2. // @name greasyfork.org langfilter
  3. // @namespace trespassersW
  4. // @include /^https?://(gr|sl)easyfork\.org/([\w-]+/)?(scripts|forum).*$/
  5. // @include https://greasyfork.org/scripts*
  6. // @description filters out scripts and posts containing non-latin letters in title
  7. // @created 2014-07-05
  8. // @updated 2019-04-11
  9. // @version 2.019.0411.2
  10. // 015-0115 fix for [https://userstyles.org/styles/109335/greasyfork-wide-scriptlist]
  11. // 019-0411 +sleezyfork
  12. // @run-at document-end
  13. // @grant GM_none
  14. // ==/UserScript==
  15. (function(){
  16. // either 'string' or /RegEx/ in title
  17. var filterz = [
  18. /[^\u0000-\u2FFF\uFB00-\uFFFF]/
  19. /* no KoC */
  20. ,/\bKOC\b|\bCamelot\b/i
  21. ,/musicbrainz/i
  22. /* */
  23. ];
  24.  
  25. var C=0,S,E;
  26. var inForum=location.href.indexOf("/forum")>-1;
  27. var locStor=null;
  28.  
  29. function toggleV(x){
  30. var t = ('N'===x)? false: ('Y'===x)? true: !S.disabled;
  31. S.disabled = t;
  32. E.innerHTML= (t?'hide':'show')+' ['+C+']';
  33. locStor && locStor.setItem("langfilter",t?'Y':'N');
  34. }
  35.  
  36. function stickStyle(css){
  37. var s=document.createElement("style"); s.type="text/css";
  38. s.appendChild(document.createTextNode(css));
  39. return (document.head||document.documentElement).appendChild(s);
  40. }
  41.  
  42. function isListed(tc, bl){
  43. if(tc) try{
  44. for(var j=0,lj=bl.length; j<lj; j++) {
  45. if( typeof bl[j] === "string" ) {
  46. if( (tc.indexOf(bl[j])>-1) ) return true;
  47. }else if( typeof bl[j].test === "function" ) { // regex ?
  48. if( bl[j].test(tc) ){
  49. return true;
  50. }
  51. }else throw "bad filterz";
  52. };
  53. } catch(e){ console.log(e+'\n j:'+j+'; tc:'+tc+'; bl:'+bl); undefined_function(); };
  54. return false;
  55. }
  56.  
  57. var listSel, titlSel;
  58. if(inForum)
  59. listSel='#Content .DataList > li.Item',
  60. titlSel=".Title";
  61. else
  62. listSel='#browse-script-list > li[data-script-type]',
  63. titlSel="h2>span.description";
  64.  
  65. var a;
  66. a = document.querySelectorAll(listSel);
  67.  
  68. if(a)
  69. for (var i=0, li=a.length, t; i<li; i++) {
  70. t=a[i].querySelector(titlSel);
  71. if(t && isListed(t.textContent, filterz)){
  72. a[i].classList.add('greazy-forq-hiden'); C++;
  73. continue;
  74. }
  75. }
  76. if(!C){
  77. return; // all clear
  78. }
  79. E=document.createElement('div');
  80. E.id="greazy-forq-info";
  81. E.style.cssText = '\
  82. position:fixed;\
  83. left:2px;top:2px;\
  84. background:rgba(255,255,255,.55);\
  85. color:#670000;border:thin dotted 0xA40;\
  86. text-shadow: #311 2px 2px 4px, #F73 -2px -2px 4px;\
  87. cursor:pointer;\
  88. ';
  89. E.addEventListener('click',toggleV,false);
  90. document.body.appendChild(E);
  91. stickStyle('\
  92. .greazy-forq-hiden{border: dotted #A40 !important;\
  93. border-width: 1px 0px 1px 2px !important;\
  94. background-color:#FFFCF4}\
  95. ');
  96. S=stickStyle('\
  97. li.greazy-forq-hiden.Item *,\
  98. li.greazy-forq-hiden > article {display:none;}\
  99. li.greazy-forq-hiden {padding:0!important;margin:0!important;\
  100. }\
  101. ');
  102.  
  103. var sh;
  104. try {
  105. locStor = window.localStorage;
  106. sh=locStor.getItem("langfilter");
  107. } catch(e){ locStor=null; }
  108. toggleV(sh||'N');
  109.  
  110. })();