User:Writ Keeper/Scripts/cookielessOrangeBar.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Writ Keeper/Scripts/cookielessOrangeBar. |
/* 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 <a href="/wiki/User_talk:' + wgUserName.replace(/ /g, '_') + '" title="User talk:'+wgUserName+'">new messages.</a> Last edit by '+lastUser+'.';
orangeBarDiv.className = "usermessage";
$("#contentSub").after(orangeBarDiv);
return;
}
}
}
});
}
});
*/