User:ThePsionic/chatmsg.js

/* SYNTAX: For running a script when you get a new message: onchatmessage = function(text, rawtext) { //Scripts to run when you get a new message return text; //DO NOT EDIT THIS LINE } For sending a new message or an inline alert, respectively: sendMessage('Message'); inlineAlert('Message'); onNewMessage.push(function(el) {	var text = $(el).find('.message').html	text = text?text:;	var wikilinks = new RegExp('([^<]*)','g')	var rawtext = text.replace(/( |	){2,}/g, ' ').replace(/]*>/g, '$1').replace(wikilinks, function(match,page,title) {return +title+''}).replace(/\[\[([^\]]*?) {2,}/g, ']*)\|\1/g, '$1').replace(/[^<]*<\/a>/g, '$1').replace('|'+wgServer+'/wiki/', wgServer+'/wiki/') //changing back to original message	var onCMCall = onchatmessage(text, rawtext);	text = onCMCall?onCMCall:text;	$(el).find('.message').html(text) }); if (typeof onchatmessage != 'function') { var onchatmessage = function(text, format) { return text; //DO NOT EDIT THIS LINE } } function inlineAlert(msg) { document.getElementsByClassName('Chat')[0].getElementsByTagName('ul')[0].innerHTML += ''+msg+''; document.getElementsByClassName('Chat')[0].scrollTop=document.getElementsByClassName('Chat')[0].scrollHeight $('[name="message"]').val('').removeAttr('disabled').focus; } function sendMessage(msg) { mainRoom.sendMessage({which: 13, shiftKey: false, preventDefault: function {}, target: $(' (qc) '+msg+' ') }) $('[name="message"]').removeAttr('disabled').focus; }