User:Akrivus/common.js

// TESTING SCRIPT

// Swearlist. // Using a double backslash '\\' is a substitute for a barrier: word\\ would trigger on forword but not on wordgame, etc. var SWEAR_LIST = ["fuck"];

// Function itself. $(function {   if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat') {		console.log("Swearchecking activated!");        var groups = mw.config.get('wgUserGroups').join(' ');        if ((groups.indexOf('bureaucrat') + groups.indexOf('sysop') + groups.indexOf('chatmoderator') + groups.indexOf('helper') + groups.indexOf('vstf') + groups.indexOf('staff')) > -6) {            $('.Chat').on('DOMNodeInserted', function(e) { var msg = $.parseHTML(e.target.innerHTML)[7]; if (msg !== void 0) { for (var i = 0; i < SWEAR_LIST.length; i++) { if (new RegExp(SWEAR_LIST[i].replace('\\', '\\b'), "mi").test(msg.innerHTML) === true) { $(' ', {								id: 'mod-ping',								src: 'http://images.wikia.com/monchbox/images/0/01/Beep-sound.ogg',								autoplay: true							}).appendTo('body'); msg.innerHTML = "" + msg.innerHTML + "<\/span>"; setTimeout(function {								if ($('#mod-ping').length) $('#mod-ping').remove;							}, 1000); }					}               }            });        }    } });