Remove livejournal-promo

Remove livejournal's promo blocks, promo-posts, hide spam-authors by list in localStorage, fix CSS.

  1. // ==UserScript==
  2. // @name Remove livejournal-promo
  3. // @name:ru Удаление промо-блоков livejournal
  4. // @version 3.2020.4.11
  5. // @description Remove livejournal's promo blocks, promo-posts, hide spam-authors by list in localStorage, fix CSS.
  6. // @description:ru Remove livejournal's promo. Удаляет промо-блоки, промо-посты из френд-ленты, скрывает спам-авторов по списку, подправляет CSS (шрифт без засечек, размеры аватаров, общий светлый фон) на некоторые группы стилей.
  7. // @namespace https://github.com/spmbt/
  8. // @include http://livejournal.com/
  9. // @include http://*.livejournal.com/
  10. // @include http://*.livejournal.com/*
  11. // @include https://livejournal.com/
  12. // @include https://*.livejournal.com/
  13. // @include https://*.livejournal.com/*
  14. // ==/UserScript==
  15.  
  16. (function(css){
  17.  
  18. var spamSList = [
  19. 'fred2265','tonyhofstra','zaven926','eduard_456' //insert your own list of spammers
  20. ]
  21. ,wrapperS = ['.appwidget.appwidget-homepage-selfpromo'
  22. ,'.appwidget.appwidget-homepage-commpromo'
  23. ,'.appwidget.appwidget-journalpromo'
  24. ,'iframe[data-link*="youtube.com/watch?v=cFvuGr0Voic"]'
  25. ,{q:'b-item-type-ad.i-friendsfeed-ad-close', parent: 4}
  26. ,{q:'a >img[src*="star-colored150.png"], a >img[src*="178679_1000.jpg"]', parent: 2} //some images
  27. ,{q:'.comment-wrap .comment-head-in >p .i-ljuser >.i-ljuser-username'
  28. +',.comments-body .comment-meta .i-ljuser >.i-ljuser-username b'
  29. +',.b-tree .b-leaf-inner .i-ljuser >.i-ljuser-username'
  30. ,spamS: spamSList //block spam by authors of comment
  31. ,parent: 5}
  32. ,{q:'.comment-wrap.partial >.i-ljuser >.i-ljuser-username'
  33. +',.comments-body .collapsed-comment .i-ljuser >.i-ljuser-username'
  34. ,spamS: spamSList //block spam by authors of wrapped comment
  35. ,parent: 2}
  36. ]
  37. ,win = typeof unsafeWindow !='undefined'? unsafeWindow : window
  38. ,$q = function(q, f){return (f||document).querySelector(q)}
  39. ,setLocStor = function(name, hh){
  40. if(!localStorage) return;
  41. localStorage['removeLj_'+ name] = JSON.stringify({h: hh});
  42. },
  43. getLocStor = function(name){
  44. return (JSON.parse(localStorage && localStorage['removeLj_'+ name] ||'{}')).h;
  45. }
  46. ,removeLocStor = function(name){localStorage.removeItem('removeLj_'+ name);}
  47. ,cleaning = function(){
  48. for(var i in wrapperS){
  49. var wI = wrapperS[i]
  50. ,wObj = typeof wI !='string'
  51. ,wQA = [].slice.call(document.querySelectorAll(wObj ? wI.q : wI) );
  52. for(var j =0; j < wQA.length; j++){
  53. var wJ = wQA[j];
  54. if(wObj && wI.spamS){ //block spam
  55. var isSpam =0;
  56. for(var k =0; k < wI.spamS.length; k++){
  57. if(wJ.innerHTML.replace(/<.*?>/g,'') == wI.spamS[k]){
  58. isSpam =1;
  59. break;}}
  60. }
  61. if(wObj && wI.parent){ //block upper
  62. for(var k =0; k < wI.parent; k++)
  63. wJ = wJ.parentNode;
  64. }
  65. if(!wObj || wObj && !wI.spamS || wObj && wI.spamS && isSpam)
  66. wJ.style.display ='none';
  67. //TODO add grey blocks
  68. }
  69. //TODO add supress by click
  70. }};
  71. cleaning();
  72. spamSList = getLocStor('spamList') || spamSList;
  73. //TODO button to add to spamList
  74. var Tout = function(h){
  75. var th = this;
  76. (function(){
  77. if((h.dat = h.check(h.t) )) //wait of positive result, then occcurense
  78. h.occur();
  79. else if(h.i-- >0) //next slower step
  80. th.ww = window.setTimeout(arguments.callee, (h.t *= h.m) );
  81. })();
  82. };
  83.  
  84. new Tout({t:320, i:6, m: 1.6 //нижний баннер
  85. ,check: function(t){
  86. return document && $q('.b-discoverytimes-wrapper');
  87. }
  88. ,occur: function(){
  89. var underBanner = this.dat;
  90. underBanner &&(underBanner.style.display = 'none');
  91. }
  92. });
  93. new Tout({t:370, i:6, m: 1.6
  94. ,check: function(t){
  95. return document && $q('.s-body #comments .b-tree-root .b-leaf');
  96. }
  97. ,occur: cleaning
  98. });
  99.  
  100. (function(css){ //addRules
  101. console.log('22221', typeof GM_addStyle, typeof addStyle);
  102. if(typeof GM_addStyle !='undefined') GM_addStyle(css); //Fx,Chr
  103. else if(typeof addStyle !='undefined') addStyle(css);
  104. else{ //Op12
  105. var heads = document.getElementsByTagName('head');
  106. if(heads.length){
  107. var node = document.createElement('style');
  108. node.type ='text/css';
  109. node.appendChild(document.createTextNode(css));
  110. heads[0].appendChild(node);
  111. }}
  112. })(css);
  113.  
  114. })('body{background: transparent!important} html, body, .comment-wrap partial, .comment-wrap, .comment-text{font-family: sans-serif!important}' //common BGs
  115. +'#page{background: none!important}'
  116. +'#page{background-color: #f6f6f8!important}'
  117. +'.header a:link, .header a:visited, .sidebar a:link, .sidebar a:visited{color: #bbc!important}'
  118. +'.lj-like, iframe[id], .pagewide-wrapper, div[id^="super_footer"]{display: none!important}' //likes under article
  119. //ava sizes
  120. +'.comment-head .comment-upic img, .comment-inner .user-icon img,.b-leaf .b-leaf-userpic-inner img, .b-leaf-userpic,'
  121. +'.comment-text .comment-meta{width: auto!important; max-height: 45px!important; margin: 0 3px 0!important; padding: 3px 3px!important}'
  122. +'.comment-head .comment-upic{width: auto!important; height: auto!important}.comment-text .comment-meta{min-height: 46px!important}'
  123. +'.b-leaf-userpic-inner{width: auto!important; height: 49px!important}'
  124. +'.b-leaf-userpic{margin-left:10px!important}'
  125. +'.b-leaf.b-leaf-collapsed .b-leaf-shorttime{margin-left:6px!important}'
  126. +'.comment-body{margin-left: 3px!important}'
  127. +'.b-leaf.b-leaf-poster, .b-leaf-username{margin: 0!important}'
  128. +'.b-leaf{margin: 8px 0 4px!important}'
  129. +'.b-singlepost-wrapper, .b-tree-twig,.content .entry-wrap,.comment-wrap{max-width: 800px}'
  130. );