Remove spammers comments livejournal-users

Hide spam-authors by list.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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

})();