User:Turbo Velocity the Time Traveling Super Speedster/chat.js

// BlockList $(function {   if (mw.config.get('wgCanonicalSpecialPageName') !== 'Chat' || $('#ignore-list').length) return;    if ( localStorage.getItem('chat-blocked') === null ) localStorage.setItem('chat-blocked', '[]');    $('head').append('');    var updateIgnore = function {        var usrs = JSON.parse(localStorage.getItem('chat-blocked'));        var html = '#Chat_17 li[data-user="' + usrs.join('"],li[data-user="') + '"]{height:0 !important;min-height: 0 !important;overflow:hidden !important;display:none !important;padding:0 !important;margin:0 !important;}#Chat_17  li[data-user="' + usrs.join('"] .username,li[data-user="') + '"] *{height:0 !important;min-height: 0 !important;overflow:hidden !important;display:none !important;padding:0 !important;margin:0 !important;}';        $('#ignore-list').html(html);    };    if ( localStorage.getItem('chat-blocked') )         updateIgnore; $('[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('chat-blocked')).join(', ').replace(/, (?!.*, )/, ', and ') + '.');                mainRoom.viewDiscussion.scrollToBottom;            } else if ( /^(!|\/|\\)block/i.test(val) ) {                this.value = ;                var toBlock = val.slice(7).trim;                var arr = JSON.parse(localStorage.getItem('chat-blocked'));                var idx = arr.indexOf(toBlock);                if ( idx === -1) {                    arr.push(toBlock);                    localStorage.setItem('chat-blocked', JSON.stringify(arr));                    updateIgnore; mainRoom.viewDiscussion.chatUL.append('' + toBlock + ' Has been blocked. Blocked users: ' + JSON.parse(localStorage.getItem('chat-blocked')).join(', ').replace(/, (?!.*, )/, ', and ') + '.'); mainRoom.viewDiscussion.scrollToBottom; } else { mainRoom.viewDiscussion.chatUL.append('' + toBlock + ' Is already blocked. Blocked users: ' + JSON.parse(localStorage.getItem('chat-blocked')).join(', ').replace(/, (?!.*, )/, ', and ') + '.'); mainRoom.viewDiscussion.scrollToBottom; }           } else if ( /^(!|\/|\\)unblock/i.test(val) ) { this.value = ''; var toUnblock = val.slice(9).trim; var array = JSON.parse(localStorage.getItem('chat-blocked')); var index = array.indexOf(toUnblock); if (index > -1) { array.splice(index, 1); localStorage.setItem('chat-blocked', JSON.stringify(array)); updateIgnore; mainRoom.viewDiscussion.chatUL.append('' + toUnblock + ' Has been unblocked. Blocked users: ' + JSON.parse(localStorage.getItem('chat-blocked')).join(', ').replace(/, (?!.*, )/, ', and ') + '.'); mainRoom.viewDiscussion.scrollToBottom; } else { mainRoom.viewDiscussion.chatUL.append('' + toUnblock + ' Isn\'t blocked; can\'t unblock.'); mainRoom.viewDiscussion.scrollToBottom; }           }        }    }); });