User:Joshua Scott/Scripts/pageage.js

$(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 += " Created on " + revision.timestamp + " by " + revision.user + " (talk • contribs)";    		}    	}  	}); }