importScript('User:Animum/urlparameters.js');
importScript('User:Animum/formatresponse.js');
importScript('User:Animum/moveRV-movefunc.js');
function zeroPad(str) {
return ("0" + str).slice(-2);
}
var isSysop = /sysop/.test(wgUserGroups);
function isBlocked(name) {
var req = sajax_init_object();
req.open("GET", wgScriptPath + "/api.php?action=query&list=blocks&bkusers=" + name + "&format=json", false);
req.send(null);
var info = eval("(" + req.responseText + ")");
return (info.query.blocks[0] ? true : false);
}
function blockip(name) {
// Safeguards against errors
if(isBlocked(name)) {
document.getElementById("contentSub").innerHTML += "<br /><br /><b>Error: " + name + " is already blocked. Defaulting to protection...</b>";
protect("User talk:" + name);
return;
}
if(name == "undefined") {
document.getElementById("contentSub").innerHTML += "<br /><br /><b>Error: No valid username was given; please block manually.";
return;
}
//If none of these safeguards have been triggered, continue.
var req = sajax_init_object();
req.open("GET", wgScriptPath + "/index.php?title=Special:BlockIP/" + name, false);
req.send(null);
document.getElementById("contentSub").innerHTML += "<br /><br />";
var edittoken = req.responseText.split('<input name="wpEditToken" type="hidden" value="')[1].split('" />')[0];
var postdata = "wpBlockAddress=" + encodeURIComponent(name)
+ "&wpBlockOther=indefinite"
+ "&wpBlockReason=" + encodeURIComponent("Page-move vandalism")
+ "&wpBlockReasonList=other"
+ "&wpEmailBan=0"
+ "&wpCreateAccount=1"
+ "&wpEnableAutoblock=1"
+ "&wpAllowUsertalk=0"
+ "&wpEditToken=" + encodeURIComponent(edittoken)
+ "&wpBlock=block";
var req = sajax_init_object();
req.open("POST", wgScriptPath + "/index.php?title=Special:BlockIP&action=submit", false);
req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
req.setRequestHeader('Content-length', postdata.length);
req.send(postdata);
if(isBlocked(name)) { //Make sure we really are done.
document.getElementById("contentSub").innerHTML += "<b>" + name + " has been blocked.</b>";
revertmoves();
}
}
function beginRectification() {
var doContinue = confirm("This script will block " + unescape(UrlParameters["user"].replace(/[+_]/g, " ")) + ", protect his/her talk page, revert ALL of his/her moves, and delete the redirects created therefrom.\n\nClick \"OK\" to continue, or \"Cancel\" to abort.");
if(doContinue) {
blockip(unescape(UrlParameters["user"]).replace(/[+_]/g, " "));
} else {
alert("Aborted.");
}
}
addOnloadHook(function() {
if(wgNamespaceNumber == -1 && wgCanonicalSpecialPageName == "Log" && (UrlParameters["type"] == "move" || location.href.substring(location.href.indexOf("title=") + 6).split("/")[1] == "move" || location.href.substring(location.href.indexOf("/wiki/") + 6).split("?")[0].split("/")[1] == "move") && (UrlParameters["user"] || location.href.substring(location.href.indexOf("user=") + 5))) {
mw.util.addPortletLink("p-cactions", "javascript:beginRectification()", "pagemove-severe", "ca-pagemoveSevere");
}
});