User:Ahecht/Scripts/massmove.js
//jshint maxerr:512
var massMoveTitle = "Mass-move tool";
/*Forked version of User:Plastikspork/massmove.js that adds a link to the left column
and allows adding and removing both prefixes and suffixes
Add the following line to Special:MyPage/common.js or :meta:Special:MyPage/global.js to install:
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/Scripts/massmove.js&action=raw&ctype=text/javascript' ); //User:Ahecht/Scripts/massmove.js User:Plastikspork/massmove.js
Click on "Mass move" under "Tools" to use the script.*/
mw.loader.using( [ 'mediawiki.api', 'mediawiki.util' ], function () {
var config = mw.config.get([
'wgServer', 'wgScript', 'wgArticlePath', 'wgFormattedNamespaces',
'wgUserGroups', 'wgNamespaceNumber', 'wgTitle',
'wgCanonicalSpecialPageName', 'wgUserName', 'skin'
]);
var mmScriptPrefix = ":en:User:Ahecht/sandbox/Scripts/",
mmScriptName = "massmove",
mmCore = `${mmScriptPrefix+mmScriptName}-core.js`,
mmCoreURL = `${config.wgServer+config.wgScript}?title=${mmCore}&action=raw&ctype=text/javascript`,
mmSpecialURL = config.wgArticlePath.replace("$1",
`${config.wgFormattedNamespaces[-1]}:${mmScriptName}`),
isMover = /sysop|extendedmover|templateeditor|bot/.test(config.wgUserGroups);
if (isMover) {
mw.util.addPortletLink("p-tb", mmSpecialURL, massMoveTitle, "p-massmove", massMoveTitle);
}
if (config.wgNamespaceNumber === -1) {
if (config.wgTitle.toLowerCase() === mmScriptName.toLowerCase()) {
config.bodyContent = 'mw-content-text';
document.getElementById(config.bodyContent).innerHTML = `Loading ${massMoveTitle}...`;
console.log("Loading " + mmCoreURL);
mw.loader.getScript( mmCoreURL ).then(function() {
massMove(massMoveTitle, config);
});
} else if (isMover && config.wgCanonicalSpecialPageName === 'Movepage') {
$('div.mw-heading').has('h2#Subpages').next('p').html( (_, t) => t.replace('\n', ' ('+mmScriptName+')\n'));
}
}
});