User:Cblair91/chat-pings.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 = 'blow ?job|\\barse\\b|\\bass\\b|boner|bitch|clit|cunt|\\bcock\\b|dick|fag|f[üúùûu][çc]k|gay|jerk|nigger|nigga|penis|r.{0,2}tard|wank|whore|badwordstest|##Automated message: Ratelimit passed\\.'; 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+')','ig')), '$1 $3 '); 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 }