User:This is Paul/monobook.js: Difference between revisions
Appearance
Content deleted Content added
This is Paul (talk | contribs) DYK |
This is Paul (talk | contribs) adding script |
||
Line 1: | Line 1: | ||
importScript('User:Lightmouse/monobook.js/script.js'); |
importScript('User:Lightmouse/monobook.js/script.js'); |
||
importScript('User:Shubinator/DYKcheck.js'); //DYKcheck tool |
importScript('User:Shubinator/DYKcheck.js'); //DYKcheck tool |
||
function orangeBarOfDoom() |
|||
{ |
|||
var cookieResult = $.cookie("lastTalkpageView"); |
|||
if(cookieResult != null) |
|||
{ |
|||
var escapedUsername = wgUserName.replace(/ /g, "_"); |
|||
if(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|parsedcomment", rvlimit:"1", rvdir:"older", rvexcludeuser: wgUserName, titles: "User talk:"+wgUserName}; |
|||
$.post("/w/api.php", data, function(results) |
|||
{ |
|||
var index = Object.keys(results.query.pages)[0]; |
|||
var lastTimestamp = Date.parse(results.query.pages[index].revisions[0].timestamp); |
|||
if( cookieResult < lastTimestamp ) |
|||
{ |
|||
var lastUser = results.query.pages[index].revisions[0].user |
|||
var section = /<a href="(.+?)".+>→<\/a>/.exec(results.query.pages[index].revisions[0].parsedcomment); |
|||
var talkLink = '/wiki/User_talk:'+encodeURIComponent(escapedUsername); |
|||
if(section != null && section.length > 1) |
|||
{ |
|||
talkLink = section[1]; |
|||
} |
|||
var orangeBarDiv = document.createElement("div"); |
|||
orangeBarDiv.innerHTML = 'You have <a href="' + talkLink + '" title="User talk:'+wgUserName+'">new messages.</a> Last edit by '+lastUser+'.'; |
|||
orangeBarDiv.className = "usermessage"; |
|||
$("#contentSub").after(orangeBarDiv); |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
var d = new Date(); |
|||
$.cookie("lastTalkpageView", d.getTime(), {expires:365, path: '/'}); |
|||
} |
|||
} |
|||
$(document).ready(orangeBarOfDoom); |
Revision as of 19:05, 2 May 2013
importScript('User:Lightmouse/monobook.js/script.js');
importScript('User:Shubinator/DYKcheck.js'); //DYKcheck tool
function orangeBarOfDoom()
{
var cookieResult = $.cookie("lastTalkpageView");
if(cookieResult != null)
{
var escapedUsername = wgUserName.replace(/ /g, "_");
if(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|parsedcomment", rvlimit:"1", rvdir:"older", rvexcludeuser: wgUserName, titles: "User talk:"+wgUserName};
$.post("/w/api.php", data, function(results)
{
var index = Object.keys(results.query.pages)[0];
var lastTimestamp = Date.parse(results.query.pages[index].revisions[0].timestamp);
if( cookieResult < lastTimestamp )
{
var lastUser = results.query.pages[index].revisions[0].user
var section = /<a href="(.+?)".+>→<\/a>/.exec(results.query.pages[index].revisions[0].parsedcomment);
var talkLink = '/wiki/User_talk:'+encodeURIComponent(escapedUsername);
if(section != null && section.length > 1)
{
talkLink = section[1];
}
var orangeBarDiv = document.createElement("div");
orangeBarDiv.innerHTML = 'You have <a href="' + talkLink + '" title="User talk:'+wgUserName+'">new messages.</a> Last edit by '+lastUser+'.';
orangeBarDiv.className = "usermessage";
$("#contentSub").after(orangeBarDiv);
}
})
}
}
else
{
var d = new Date();
$.cookie("lastTalkpageView", d.getTime(), {expires:365, path: '/'});
}
}
$(document).ready(orangeBarOfDoom);