User:Sj/vector.js

function orangeBarOfDoom {	var cookieResult = $.cookie("lastTalkpageView"); if(cookieResult != null) {		var escapedUsername = mw.config.get('wgUserName').replace(/ /g, "_"); if(mw.config.get('wgPageName') == "User_talk:"+ escapedUsername) {			var d = new Date; $.cookie("lastTalkpageView", d.getTime, {expires:365, path: '/'}); }		else {			var data = {action: "query", prop:"revisions", format:"json", rvprop:"timestamp|user", rvlimit:"1", rvdir:"older", rvexcludeuser: mw.config.get('wgUserName'), titles: "User talk:"+mw.config.get('wgUserName')}; $.post("/w/api.php", data, function(results)			{				var index = Object.keys(results.query.pages)[0];				var lastUser = results.query.pages[index].revisions[0].user				var lastTimestamp = Date.parse(results.query.pages[index].revisions[0].timestamp);				if( cookieResult < lastTimestamp )				{					var orangeBarDiv = document.createElement("div");					orangeBarDiv.innerHTML = 'You have new messages. Last edit by '+lastUser+'.';					orangeBarDiv.className = "usermessage";					$("#contentSub").after(orangeBarDiv);				}			}) }	}	else {		var d = new Date; $.cookie("lastTalkpageView", d.getTime, {expires:365, path: '/'}); } } // (comment out) $(document).ready(orangeBarOfDoom);