User:Writ Keeper/Scripts/cookielessOrangeBar.js

/* OBSOLETE, DO NOT USE: User:Writ Keeper/Scripts/orangeBar.js is the correct location for this script.

$(document).ready(function {	var numNotes = /\d+/.exec($("#pt-notifications").text)[0];	if(numNotes == null)	{		var data = {action:"query", meta:"notifications", format:"json", notprop:"count"};		$.post("/w/api.php", data, function(result) {			numNotes = result.query.notifications.count; });	}	if(numNotes > 0)	{		var firstData = {action:"query", meta:"notifications", format:"json", notprop:"list",notlimit:numNotes}		$.post("/w/api.php", firstData, function(firstResponse) {			var keyArray = Object.keys(firstResponse.query.notifications.list) if((wgCanonicalNamespace + ":" + wgTitle) == ("User_talk:" + wgUserName)) {				var idString = ""; for(i = 0; i < keyArray.length; i++) {					if(firstResponse.query.notifications.list[keyArray[i]].category == "edit-user-talk" && typeof firstResponse.query.notifications.list[keyArray[i]].read == "undefined") {						idString = idString + keyArray[i] + "|"; }				}				if(idString.length > 0) {					var secondData = {action:"query", meta:"notifications", format:"json", notlimit:"1", notmarkread:idString}; $.post("/w/api.php", secondData); }			}			else {				for(i = 0; i < keyArray.length; i++) {					if(firstResponse.query.notifications.list[keyArray[i]].category == "edit-user-talk" && typeof firstResponse.query.notifications.list[keyArray[i]].read == "undefined") {						var lastUser = firstResponse.query.notifications.list[keyArray[i]].agent.name; var orangeBarDiv = document.createElement("div"); orangeBarDiv.innerHTML = 'You have new messages. Last edit by '+lastUser+'.'; orangeBarDiv.className = "usermessage"; $("#contentSub").after(orangeBarDiv); return; }				}			}		});	} });