Remove spammers comments livejournal-users

Hide spam-authors by list.

  1. // ==UserScript==
  2. // @name Remove spammers comments livejournal-users
  3. // @name:ru Удаление спамерских комментариев пользователей livejournal
  4. // @version 0.2
  5. // @description Hide spam-authors by list.
  6. // @description:ru Скрывает спам-авторов по списку
  7. // @include http://livejournal.com/
  8. // @include http://*.livejournal.com/
  9. // @include http://*.livejournal.com/*
  10. // @include https://livejournal.com/
  11. // @include https://*.livejournal.com/
  12. // @include https://*.livejournal.com/*
  13. // @namespace https://greasyfork.org/users/828699
  14. // ==/UserScript==
  15.  
  16. (function(){
  17.  
  18. var spamSList = [
  19.  
  20. //insert your own list of spammers
  21. ];
  22.  
  23. var wrapperS = [
  24. {q:'.comment-wrap .comment-head-in >span .i-ljuser >.i-ljuser-username'
  25. +',.comments-body .comment-meta .i-ljuser >.i-ljuser-username b'
  26. +',.b-tree .b-leaf-inner .i-ljuser >.i-ljuser-username'
  27. ,parent: 5},
  28. {q:'.comment-wrap.partial >.i-ljuser >.i-ljuser-username'
  29. +',.comments-body .collapsed-comment .i-ljuser >.i-ljuser-username'
  30. ,parent: 2},
  31. ];
  32. var win = typeof unsafeWindow !='undefined'? unsafeWindow : window;
  33. var $q = function(q, f){return (f||document).querySelector(q)};
  34. var setLocStor = function(name, hh){
  35. if(!localStorage) return;
  36. localStorage['removeLj_'+ name] = JSON.stringify({h: hh});
  37. };
  38. var getLocStor = function(name){
  39. return (JSON.parse(localStorage && localStorage['removeLj_'+ name] ||'{}')).h;
  40. };
  41. var removeLocStor = function(name){localStorage.removeItem('removeLj_'+ name);};
  42. var cleaning = function(){
  43. for(let i =0; i < wrapperS.length; i++){
  44. let wI = wrapperS[i];
  45. let wQA = [].slice.call(document.querySelectorAll(wI.q) );
  46.  
  47. for(let j =0; j < wQA.length; j++){
  48. var wJ = wQA[j];
  49. //block spam
  50. var isSpam =0;
  51. for(let k =0; k < spamSList.length; k++){
  52. if(wJ.innerHTML.replace(/<.*?>/g,'') == spamSList[k]){
  53. isSpam =1;
  54. break;
  55. }
  56. }
  57. if(isSpam) {
  58. for(let k =0; k < wI.parent; k++) {
  59. wJ = wJ.parentNode;
  60. }
  61. wJ.style.display ='none';
  62. //TODO add grey blocks
  63. }
  64. }
  65. //TODO add supress by click
  66. }
  67. };
  68. cleaning();
  69. LJ.Event.on("afterCommentExpand", cleaning);
  70. //spamSList = getLocStor('spamList') || spamSList;
  71. //TODO button to add to spamList
  72.  
  73. })();