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(mw.config.get('wgUserGroups'));

function doMoveRV() {
    var domove = confirm("All of the moves listed on this page will be reverted" + (isSysop ? ", and the resulting redirects will be deleted" : "") + ".\n\nClick \"OK\" to proceed or \"Cancel\" to abort.");
    if(domove) {
        revertmoves(); //Function contained in moveRV-movefunc.js
    } else {
        return;
    }
}

addOnloadHook(function() {
    if(mw.config.get('wgNamespaceNumber') == -1 && mw.config.get('wgCanonicalSpecialPageName') == "Log" && (UrlParameters == "move" || location.href.substring(location.href.indexOf("title=") + 6).split("/") == "move" || location.href.substring(location.href.indexOf("https://wikines.com/en/") + 6).split("?").split("/") == "move") && (UrlParameters || location.href.substring(location.href.indexOf("user=") + 5))) {
        mw.util.addPortletLink("p-cactions", "javascript:doMoveRV()", "pagemove", "ca-pagemove");
    }
});