User:DeadManTyping/monobook.js

if (wgNamespaceNumber ==0) { var req = null;

if(window.XMLHttpRequest) req = new XMLHttpRequest; else if (window.ActiveXObject) req = new ActiveXObject(Microsoft.XMLHTTP);

req.onreadystatechange = function { if(req.readyState == 4) { if(req.status == 200) {      var PageInfo= eval('(' + req.responseText + ')'); for(pages in PageInfo.query.pages) {    alert(PageInfo["query"]["pages"][pages].templates.length); var templateList=PageInfo["query"]["pages"][pages].templates; } }	else { alert("Error: returned status code " + req.status + " " + req.statusText); }	} }; var escapedTitle=escape(wgTitle);

req.open("GET", "http://en.wikipedia.org/w/api.php?action=query&titles="+escapedTitle+"&prop=templates&format=json", true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

req.send(null); alert(templateList[0].title);

}