User:Joeytje50/ratelimit.js

var rate = 0; function ratelimit(e) { if (rate > 5) { this.disabled = true;//disabling input in case they press ESC before the redirect is complete e.preventDefault; $('[name="message"]').val('##Automated message: Ratelimit passed. If necessary, click here to ban me from the chat.'); mainRoom.sendMessage({which : 13, shiftKey : false, preventDefault : function {} }) document.location.href = "http://runescape.wikia.com/wiki/RuneScape:Chat/Ratelimit_triggered"; return false; }	if (this.value.length>=1000 || this.value.split('\n').length>=6) { val = this.value.substring(0,1000).split('/n'); val = val[0]+val[1]+val[2]+val[3]+val[4];//remove all lines after the 5th line. this.value = val; if (e.type == 'keypress') { e.preventDefault; return false; }	}	if (e.type == 'keypress' && e.which == 13) { rate += 1; setTimeout(function {			if (rate > 0) { rate -= 1 }		},5000); } } $('[name="message"]').keyup(ratelimit).keypress(ratelimit).keydown(ratelimit);