User:Dtrebbien/NewpagesPatrolTool.html

 // <!--

function addLinkToContentBeforeFirstHeading(onclick, innerHTML) {  var content=document.getElementById("content"); var a=document.createElement("a"); a.href="#"; a.onclick=onclick; a.innerHTML=innerHTML; content.insertBefore(a,content.getElementsByTagName("h1")[0]); }

function doAsynchronousEdit(title, newtext) {  title=title.replace(/ /g,'_');

if(window.XMLHttpRequest) {     var xhr=new XMLHttpRequest; xhr.open("GET","http://en.wikipedia.org/w/index.php?title="+title+"&action=edit",true); if(xhr.overrideMimeType) xhr.overrideMimeType("text/html"); xhr.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT"); xhr.setRequestHeader("Connection","close");

xhr.onreadystatechange=function { if(xhr.readyState==4) {           if(xhr.status==200) {              var responseXML=xhr.responseXML;

var editform=responseXML.getElementById("editform"); var oldtext=editform.wpTextbox1.value;

var xhr2=new XMLHttpRequest; if(xhr2.overrideMimeType) xhr2.overrideMimeType("text/plain"); xhr2.open("POST",                        "http://en.wikipedia.org/w/index.php",                         true); xhr2.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); xhr2.setRequestHeader("Connection","close"); var encodeParam=function(key,val) { return key+"="+encodeURIComponent(val).replace(/%20g/,"+"); };              var body=encodeParam("title",title)+"&"+ encodeParam("action","submit")+"&"+ encodeParam("wpStarttime",editform.wpStarttime.value)+"&"+ encodeParam("wpEdittime",editform.wpEdittime.value)+"&"+ encodeParam("wpTextbox1",newtext+"\n\n"+oldtext)+"&"+ encodeParam("wpSummary","(semi-automatically) added `"+newtext+"`")+"&"+ encodeParam("wpMinoredit","1")+"&"+ encodeParam("wpSave","Save page")+"&"+ encodeParam("wpEditToken",editform.wpEditToken.value)+"&"+ encodeParam("wpAutoSummary",editform.wpAutoSummary.value); xhr2.setRequestHeader("Content-Length",body.length); xhr2.onreadystatechange=function { if(xhr2.readyState==4) {                    var w=window.open("about:blank","","width=500,height=500"); if(w) {                       w.document.write(xhr2.responseText); }                    else {                       if(xhr2.status==200) window.alert("Success!"); else window.alert("Failure."); }                 }               };               xhr2.send(body); }           else window.alert("Error: HTTP status "+xhr.status); }     };

xhr.send(null); }  else window.alert("Error: Your browser must support window.XMLHttpRequest"); }

if(window==window.parent) window.alert("Error: The Special:Newpages Patrol Tool is not meant to be accessed directly."); else {  // grab a list of new pages var xhr=new XMLHttpRequest; if(xhr.overrideMimeType) xhr.overrideMimeType("text/html"); xhr.open("GET","http://en.wikipedia.org/w/index.php?title=Special:Newpages&namespace=0&limit=100&offset=0&action=render",true); xhr.setRequestHeader("Connection","close");

xhr.onreadystatechange=function { if(xhr.readyState==4) {        var ol=xhr.responseXML.getElementsByTagName("ol"); for(var li in ol.getElementsByTagName("li")) {           document.appendChild(li.firstChild); }     }   };

xhr.send(null); }

// -->