greatest.deepsurf.us langfilter

filters out scripts and posts containing incomprehensible letters in title

As of 2014-07-06. See the latest version.

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