cillibombombom / Investing User Blocker

// ==UserScript==
// @name         Investing User Blocker
// @version       1.1.1
// @grant   none
// @match  http://uk.investing.com/*
// @match  http://in.investing.com/*
// @match  http://ca.investing.com/*
// @match  http://au.investing.com/*
// @match  http://za.investing.com/*
// @match  http://de.investing.com/*
// @match  http://es.investing.com/*
// @match  http://mx.investing.com/*
// @match  http://fr.investing.com/*
// @match  http://it.investing.com/*
// @match  http://nl.investing.com/*
// @match  http://pl.investing.com/*
// @match  http://pt.investing.com/*
// @match  http://br.investing.com/*
// @match  http://ru.investing.com/*
// @match  http://tr.investing.com/*
// @match  http://sa.investing.com/*
// @match  http://gr.investing.com/*
// @match  http://se.investing.com/*
// @match  http://fi.investing.com/*
// @match  http://il.investing.com/*
// @match  http://jp.investing.com/*
// @match  http://kr.investing.com/*
// @match  http://cn.investing.com/*
// @match  http://hk.investing.com/*
// @match  http://id.investing.com/*
// @match  http://ms.investing.com/*
// @match  http://th.investing.com/*
// ==/UserScript==

(function($){
    block();
    var blockedUsers, value;
    $(".commentBody").hover(
        function() {
            $( this ).append( $('<input/>').attr({ type: 'button', value:'block user', id: "blockButon"}) );
            $( "#blockButon" ).click(function() {
                 blockedUsers = localStorage.getItem('blockedUsers');
                if(blockedUsers === null){
                    blockedUsers = [];
                }else{
                    blockedUsers = blockedUsers.split(",");
                }
                blockedUsers.push($(this).context.parentElement.children[0].innerText);
                localStorage.setItem('blockedUsers', blockedUsers);
                block();
            });
        },function() {
            $( this ).find( "input:last" ).remove();
        }
    );
    function block(){
        value = $(".commentBody");
        blockedUsers = localStorage.getItem('blockedUsers');
        if(blockedUsers === null){
            blockedUsers = [];
        }
        for(var i=0; i < value.length; i++){
            if(blockedUsers.indexOf(value[i].firstElementChild.innerText) >= 0){
                value[i].parentElement.remove();
            }
        }
    }
})(jQuery);