MediaWiki:Chat.js

//////////////////////////////////////////// /* Function to color nicknames of users in the chat, based on their nickname. */ function colorNickNames { if ($('.username:not([style])').length) { $('.username:not([style])').replaceWith(function {	var string = this.innerHTML;	var strlen = string.length	var asciistr = 0;	var addnum = 0;	for (i = 0; i < strlen; i++) {		if (string.charAt(i).match(/[a-z]/i)) {			asciistr += string.charCodeAt(i) - 96;		} else if (string.charAt(i).match(/\d/)) {			asciistr += string.charCodeAt(i) - 47;		} else {			asciistr += string.charCodeAt(i);			addnum += string.charCodeAt(i);		}	}	var color = parseInt(asciistr/(26*string.replace(/[^a-zA-Z0-9]/g,'').length+addnum)*16777215).toString(16);	var nickColor = [0,0,0];	nickColor[0] = parseInt(color.charAt(0)+color.charAt(1),16);	nickColor[1] = parseInt(color.charAt(2)+color.charAt(3),16);	nickColor[2] = parseInt(color.charAt(4)+color.charAt(5),16);	nickColor[0] = nickColor[0]>200?nickColor[0]-100:nickColor[0];	nickColor[1] = nickColor[1]>200?nickColor[1]-100:nickColor[1];	nickColor[2] = nickColor[2]>200?nickColor[2]-100:nickColor[2]; nickColor = 'rgb('+nickColor[0]+','+nickColor[1]+','+nickColor[2]+')'; return ']*>/i,''))+'" class="username" style="color:'+nickColor+';font-weight:bold;">'+this.innerHTML+'' }) } } onchatmessage = function(text, rawtext) {	setTimeout(colorNickNames, 20)	text = text.replace('<img src="http://i.imgur.com/DexQI.png" width="19" height="19"', '<img src="http://images2.wikia.nocookie.net/runescape/images/d/de/Quick_chat_button.png" width="13" height="10"')	return text; //DO NOT EDIT THIS LINE } function pad(n) {//Function to pad the timestamps with zeroes where needed	return (n<10?'0':'') + n; } function markAdmins {	$('.WikiChatList .User.chat-mod .username').each(function { if (!this.innerHTML.match(/BicycleCat|Casting Fishes\^\^|Cåm|Hairrazerrr|Hofmic|Hydro1|Joeytje50|Smithing|Touhou FTW|Vulpes Twigy/)) { $(this).addClass('admin'); }	}); } function markBots {       $('.WikiChatList .User .username').each(function { if (this.innerHTML.match(/RSChatBot/)) { $(this).addClass('bot'); }        }); } function markVstf {        $('.WikiChatList .User .username').each(function { if (this.innerHTML.match(/Deltaneos|Eulalia459678|Nifky|Ohmyn1|Randomtime|Rappy 4187|Sactage|Sulfur|VegaDark/)) { $(this).addClass('vstf'); }         }); } setInterval(markAdmins, 1000) setInterval(markBots, 1000) setInterval(markVstf, 1000)