User:Joshua Scott/Scripts/pageage.js
Appearance
(Redirected from User:LiberalFascist/Scripts/pageage.js)
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:Joshua Scott/Scripts/pageage. |
$(document).ready(pageage_init());
function pageage_init() {
var site_sub = document.getElementById('siteSub');
if (!site_sub) return; // Bail out if this is not a normal page view.
var apiUrl = "/w/api.php?action=query&format=json&prop=revisions&titles="+wgPageName+"&rvlimit=1&rvprop=timestamp|user&rvdir=newer";
$.ajax({
url: apiUrl,
success: function(data) {
var page_id = Object.keys(data.query.pages)[0];
if (page_id === "-1") { // New page, e.g.
return;
} else {
var revision = data.query.pages[page_id].revisions[0];
var site_sub = document.getElementById('siteSub');
site_sub.innerHTML += "<br/>Created on " + revision.timestamp + " by <a href='/wiki/User:" + revision.user + "'>" + revision.user + "</a> (<a href='/wiki/User_talk:" + revision.user + "'>talk</a> • <a href='/wiki/Special:Contributions/" + revision.user + "'>contribs</a>)";
}
}
});
}