User:Rjd0060/oldprod.js

// importScript('User:Animum/urlparameters.js'); //For the "UrlParameters[]" below. $(function { if(wgNamespaceNumber == 1 && UrlParameters["action"] == "edit" && UrlParameters["oldprod"] == 1) { var xmlreq = new XMLHttpRequest;  xmlreq.open("GET", "http://en.wikipedia.org/w/api.php?action=query&list=logevents&ledir=older&leprop=timestamp&letype=delete&letitle=" + encodeURIComponent(wgPageName.split(":")[1]) + "&format=xml", true);  xmlreq.send("");  xmlreq.onreadystatechange = function {   if(xmlreq.readyState == 4 && xmlreq.status == 200) { //Crucial XML fluff.    var item = xmlreq.responseXML.getElementsByTagName("item")[(document.getElementById("ca-nstab-main").getElementsByTagName("a")[0].getAttribute("href").indexOf("action=edit") != -1 ? 0 : 1)]; //Is the article existent or not? If so, do not fetch the restoration date.    document.editform.wpTextbox1.value = "\n" + document.editform.wpTextbox1.value; //Add it to the editform.    document.editform.wpMinoredit.checked = false;    document.editform.wpWatchthis.checked = false;    document.editform.wpSummary.value = "Tagging with ";    document.editform.submit;   }  }; } }); $(function { if(wgNamespaceNumber == 1) mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(mw.config.get('wgPageName')) + "&action=edit&oldprod=1", "oldprod", "ca-oldprod"); }); //