Remove spammers comments livejournal-users

Hide spam-authors by list.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Remove spammers comments livejournal-users
// @name:ru     Удаление спамерских комментариев пользователей livejournal
// @version     0.2
// @description Hide spam-authors by list.
// @description:ru Скрывает спам-авторов по списку
// @include     http://livejournal.com/
// @include     http://*.livejournal.com/
// @include     http://*.livejournal.com/*
// @include     https://livejournal.com/
// @include     https://*.livejournal.com/
// @include     https://*.livejournal.com/*
// @namespace https://greasyfork.org/users/828699
// ==/UserScript==

(function(){

    var spamSList = [

        //insert your own list of spammers
    ];

    var wrapperS = [
        {q:'.comment-wrap .comment-head-in >span .i-ljuser >.i-ljuser-username'
         +',.comments-body .comment-meta .i-ljuser >.i-ljuser-username b'
         +',.b-tree .b-leaf-inner .i-ljuser >.i-ljuser-username'
         ,parent: 5},
        {q:'.comment-wrap.partial >.i-ljuser >.i-ljuser-username'
         +',.comments-body .collapsed-comment .i-ljuser >.i-ljuser-username'
         ,parent: 2},
    ];
    var win = typeof unsafeWindow !='undefined'? unsafeWindow : window;
	var $q = function(q, f){return (f||document).querySelector(q)};
	var setLocStor = function(name, hh){
		if(!localStorage) return;
		localStorage['removeLj_'+ name] = JSON.stringify({h: hh});
	};
	var getLocStor = function(name){
		return (JSON.parse(localStorage && localStorage['removeLj_'+ name] ||'{}')).h;
	};
	var removeLocStor = function(name){localStorage.removeItem('removeLj_'+ name);};
	var cleaning = function(){
		for(let i =0; i < wrapperS.length; i++){
			let wI = wrapperS[i];
            let wQA = [].slice.call(document.querySelectorAll(wI.q) );

            for(let j =0; j < wQA.length; j++){
				var wJ = wQA[j];
				//block spam
                var isSpam =0;
                for(let k =0; k < spamSList.length; k++){
                    if(wJ.innerHTML.replace(/<.*?>/g,'') == spamSList[k]){
                        isSpam =1;
                        break;
                    }
                }
                if(isSpam) {
                    for(let k =0; k < wI.parent; k++) {
                        wJ = wJ.parentNode;
                    }
                    wJ.style.display ='none';
                    //TODO add grey blocks
                }
            }
			//TODO add supress by click
		}
    };
    cleaning();
    LJ.Event.on("afterCommentExpand", cleaning);
	//spamSList = getLocStor('spamList') || spamSList;
	//TODO button to add to spamList

})();