User:Ultimate Dark Carnage/sandbox2.js

(function($,mw){   importArticles({ type: 'script', articles: [ 'User:Ultimate_Dark_Carnage/keycode.js' ]   });    var badWords = [];    $.get('/index.php?title=MediaWiki:Badwords&action=raw', function(data){ if (data){ badWords = data.split('\n'); } else { console.log('Operation failed!'); }   });    function censor(element, text){        var badWordRegExp = new RegExp(badWords.join('|'), 'gi');        $(element).html(text.replace(badWordRegExp, ' $1 '));    }    if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat' || mw.config.get('wgPageName') == 'Special:Chat'){        $('.ChatWindow').on('DOMNodeInserted', '.Chat li:last .message', function(event){ censor(event.target, $(event.target).html); });   }    console.log(badWords); })(jQuery, mediaWiki);