Jump to content

User:Animum/moveRV.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
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["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:doMoveRV()", "pagemove", "ca-pagemove");
    }
});