User:Democritos/chat.js

// Swearing crap var SWEAR_LIST = [ "\\bfuck", "\\bmotherfuck", "\\bshit\\b", "\\bshitt", "\\bbitch", "\\bwhore\\b", "\\bgtfo\\b", "\\bstfu\\b", "\\bwtf\\b", "\\bidfk\\b", "\\bidfc\\b", "\\bidgaf\\b", "\\bidefk\\b", "\\bjfc\\b", "\\bomf", "\\bffs\\b", "\\bw t f", "\\bmilf\\b" ]; var SLUR_LIST = [ "\\bnigga\\b", "\\bnigger\\b", "\\niglet\\b", "\\bfag\\b", "\\bfagg", "\\bcunt\\b", "\\btranny\\b", "\\bdyke\\b" ]; var tempMessageValue = ''; var lmt = {}; // Function itself. $(function { if ( mw.config.get('wgCanonicalSpecialPageName') == 'Chat' ) {    console.log("Pingchecking activated!");    $('.Chat').on('DOMNodeInserted', function(e) { var msg = $.parseHTML(e.target.innerHTML)[7]; var nmg = msg.innerHTML; var mee = $(".User .username").html; var mid = e.target.id; var usr = e.target.getAttribute('data-user'); var usrSpam = usr + 'Spam'; if ( usr == mee ) return; if ( msg !== void 0 ) { if ( lmt[usrSpam] === undefined || isNaN(lmt[usrSpam]) ) { lmt[usrSpam] = 1; } else if ( lmt[usrSpam] > 7 ) { tempMessageValue = $(".message textarea").val; $(".message textarea").val(usr + ', please don\'t flood!'); $('.message textarea').trigger(jQuery.Event('keypress', { which: 13 }));           $(".message textarea").val(tempMessageValue); $(".message textarea").focus; mainRoom.kick({               name: usr            }); } else if ( typeof lmt[usrSpam] === 'number' ) { lmt[usrSpam]++; }       setTimeout(function {          if ( lmt[usrSpam] > 0 ) {            lmt[usrSpam]--;          }        }, 7000); for ( var v = 0; v < SWEAR_LIST.length; v++ ) { if ( new RegExp(SWEAR_LIST[v], "mi").test(msg.innerHTML) === true ) { if ( lmt[usr] === undefined || isNaN(lmt[usr]) ) { lmt[usr] = 1; } else if ( lmt[usr] > 5 ) { tempMessageValue = $(".message textarea").val; $(".message textarea").val(usr + ', you swore 6 times in 10 minutes, for shame! :O’'); $('.message textarea').trigger(jQuery.Event('keypress', { which: 13 }));               $(".message textarea").val(tempMessageValue); $(".message textarea").focus; mainRoom.kick({                 name: usr                }); } else if ( typeof lmt[usr] === 'number' ) { lmt[usr]++; }           setTimeout(function {              if (lmt[usr] > 0) {                lmt[usr]--;              }            }, 600000); }       }        for ( var i = 0; i < SLUR_LIST.length; i++ ) { if ( new RegExp(SLUR_LIST[i], "mi").test(msg.innerHTML) === true ) { tempMessageValue = $(".message textarea").val; $(".message textarea").val(usr + ', please don\'t use slurs!'); $('.message textarea').trigger(jQuery.Event('keypress', { which: 13 }));           $(".message textarea").val(tempMessageValue); $(".message textarea").focus; mainRoom.kick({             name: usr            }); }       }      }    });  } });