Trolls be gone.

Hide forum posts from blacklisted users

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

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

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.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

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!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

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

// ==UserScript==
// @name         Trolls be gone.
// @namespace    https://www.warlight.net/
// @version      0.2
// @description  Hide forum posts from blacklisted users
// @author       Master of the Dead
// @match        https://www.warlight.net/Forum/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    $.get("/ManageBlackList",function(data){
        // Fetch blacklisted players.
        var blacklist = [];
        var players = $('#MainSiteContent', data).find("li");
        players.each(function(i, player){
            var name = $(player).find("a:eq(1)")[0].innerHTML; // find the second link in the list element
            blacklist.push(name);
        });

        // Hide every post whose author is blacklisted.
        var forumPosts = $("#MainSiteContent").find("table:first").find("table");
        forumPosts.find("tr").each(function(i, post){
            var authorCell = $(post).find("td:first")[0];
            if(authorCell !== undefined && authorCell.innerText !== undefined){
                var postAuthor = authorCell.innerText;
                if(IsPostAuthorBlacklisted(postAuthor)){
                    var postContent = $(post).find("td:eq(1)")[0];
                    if(postContent !== undefined && postContent.innerText !== undefined){
                        postContent.innerText = "[Hidden as player was blacklisted]";
                        $(postContent).css("color", "#808080");
                    }
                }
            }
        });

        /* Check if author of the forum post is present in user's blacklist */
        function IsPostAuthorBlacklisted(postAuthor){
            var i = blacklist.length;
            while(i--) {
                if (postAuthor.indexOf(blacklist[i])!=-1) {
                    return true;
                }
            }
            return false;
        }
    });

})();