User:Walrus068/mass delete.js

var mass_delete = (function {	var onready = function  {		if (this.readyState === 4 && this.status === 200) {			var i, xhr, a = JSON.parse(this.responseText).query.usercontribs;			for (i = 0;  i < a.length; i = i + 1) {				if (a[i].new) {					xhr = new XMLHttpRequest;					xhr.onreadystatechange = function  {						if (this.readyState === 4 && this.status === 200) {						}					};					xhr.open("POST", "/api.php", true);					xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");					xhr.send("format=json&action=delete&title=" + encodeURIComponent(a[i].title) + "&token=" + localStorage.getItem("DeleteToken"));				}			}		}	},		string = wgScriptPath +			"/api.php?format=json&action=query&list=usercontribs&uclimit=500" +			(wgUserGroups.indexOf("sysop") > -1 ? "0" : "") +			"&ucuser=",		getDeleteToken = (function { var onready = function { if (this.readyState === 4 && this.status === 200) { sessionStorage.setItem("EditToken",						this.responseXML.getElementsByTagName("page")[0]					.getAttribute("deletetoken").replace(/\+/, "%2B")); }			};			return function { var xhr = new XMLHttpRequest; xhr.onreadystatechange = onready; xhr.open("GET",					wgScriptPath +					"/api.php?format=xml&action=query&prop=info&intoken=delete&titles=A",				false); xhr.send; };		});	return function (user) {		if (!localStorage.getItem("DeleteToken")) {			getDeleteToken;		}		var xhr = new XMLHttpRequest;		xhr.onreadystatechange = onready;		xhr.open("GET", string + encodeURIComponent(user), true);		xhr.send;	}; });