User:Hunter103/chat.js

/* Script to beep when people say your name, or bad words. This is helpful to notice people saying your name, or to notice spammers or trolls. To import this script, add the following to your Special:MyPage/chat.js page: var pings = 'phrase1|phrase2|etc'; importScript('User:Joeytje50/chat-pings.js'); onchatmessage = function(text, rawtext) { text = unameBeep(text);//remove this line if you don't want username beeps text = badWordsBeep(text);//remove this line if you don't want bad words beeps return text; //DO NOT EDIT THIS LINE } Or just add  badWordsBeep(text);  or  unameBeep(text);   to the onchatmessage function, if you already defined the function. If you do not understand the above sentence, just use the code above it. importScript('User:Joeytje50/chatmsg.js'); var pings = pings?pings:wgUserName; var badwords = 'arse|blow ?job|boner|bitch|clit|cunt|cock|dick|fag|fuck|gay|jerk|nigger|nigga|r.{0,2}tard|wank|whore|badwordstest'; if (!$('#pingsound').length) { $('body').append(' '); } function badWordsBeep(text) { text = text.replace((new RegExp('((^|>|('+badwords+'))[^<]*?)('+badwords+')','ig')), '$1 $4 '); setTimeout(function {		if ($('.Chat ul li:last-child:not(.you):not(.inline-alert) .message .badword').length && $('.Chat ul li:last-child .message').html.match(new RegExp(badwords, 'i'))) {			$('#pingsound').html(' ');		}	}, 20) return text } function unameBeep(text) { text = text.replace((new RegExp('((^|>|('+pings+'))[^<]*?)('+pings+')','ig')), '$1 $4 '); setTimeout(function {		if ($('.Chat ul li:last-child:not(.you):not(.inline-alert) .message .highlight').length && $('.Chat ul li:last-child .message').html.match(new RegExp(pings, 'i'))) {			$('#pingsound').html(' ');		}	}, 20) return text }