User:Hynza/chat.css

$(function {   if (mw.config.get('wgCanonicalSpecialPageName') !== 'Chat') return;    if ( localStorage.getItem('chatBlocked') === null ) localStorage.setItem('chatBlocked', '[]');    if ( localStorage.getItem('chatBlocked') ) {        var usrs = JSON.parse(localStorage.getItem('chatBlocked')).join('"], li[data-user="');        mw.util.addCSS('li[data-user="' + usrs + '"] { display: none; }');    }    $('[name="message"]').keypress(function (e) { if (e.which == 13) { var val = this.value; if ( /^(!|\/|\\)blocklist/i.test(val) ) { this.value = ''; mainRoom.viewDiscussion.chatUL.append('Blocked users: ' + JSON.parse(localStorage.getItem('chatBlocked')).join(', ') + '.'); } else if ( /^(!|\/|\\)block/i.test(val) ) { this.value = ''; var toBlock = val.slice(7).trim; var arr = JSON.parse(localStorage.getItem('chatBlocked')); var idx = arr.indexOf(toBlock); if ( idx === -1) { arr.push(toBlock); localStorage.setItem('chatBlocked', JSON.stringify(arr)); mw.util.addCSS('li[data-user="' + toBlock + '"] { display: none; }'); mainRoom.viewDiscussion.chatUL.append('' + toBlock + ' Has been blocked. Blocked users: ' + JSON.parse(localStorage.getItem('chatBlocked')).join(', ') + '.'); } else { mainRoom.viewDiscussion.chatUL.append('' + toBlock + ' Is already blocked. Blocked users: ' + JSON.parse(localStorage.getItem('chatBlocked')).join(', ') + '.'); }           } else if ( /^(!|\/|\\)unblock/i.test(val) ) { this.value = ''; var toUnblock = val.slice(9).trim; var array = JSON.parse(localStorage.getItem('chatBlocked')); var index = array.indexOf(toUnblock); if (index > -1) { array.splice(index, 1); localStorage.setItem('chatBlocked', JSON.stringify(array)); mw.util.addCSS('li[data-user="' + toUnblock + '"] { display: block !important; }'); mainRoom.viewDiscussion.chatUL.append('' + toUnblock + ' Has been unblocked. Blocked users: ' + JSON.parse(localStorage.getItem('chatBlocked')).join(', ') + '.'); } else { mainRoom.viewDiscussion.chatUL.append('' + toUnblock + ' Isn\'t blocked; can\'t unblock.'); }           }        }    }); });