Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
//<nowiki>

//catALot///////////////////////////////////////
////////// Cat-A-Lot user preferences //////////
window.catALotPrefs = {"watchlist":"preferences","minor":true,"editpages":false,"docleanup":true,"subcatcount":0};
////////////////////////////////////catALotEnd//
//</nowiki>
//<nowiki>

//vFCvFCCfg/////////////////////////////////////
/////// VISUAL FILE CHANGE CONFIGURATION ///////
///// DO NOT MODIFY BY HAND - FINGERS AWAY! ////
////////////////////////////////////////////////
window.vFCSettings = {"userNote":"Yours sincerely,","firstTest":0,"testEdits":0,"defaultAction":"c_replace","watchlistUserTalk":"preferences","watchlistFiles":"preferences","watchlistReplace":"nochange","watchlistOTRS":"nochange","loadBatchSize":600,"maxSimultaneousReq":10,"summaryChacheLen":5,"loadThumbs":true,"loadWikitext":true};
//////////////////////////////////vFCvFCCfgEnd//
//</nowiki>

importScript( 'MediaWiki:Commander.js ');

window.AjaxDeleteExtraButtons = [
                {
                    'label': 'Speedy Recreation DR',
                    'tag': '{'+'{speedy|1=[[COM:CSD#G4]], Recreation of content previously deleted per community consensus.}}',
                    'img_summary': 'Requesting speedy deletion because of [[COM:CSD#G4]], Recreation of content previously deleted per community consensus.',
                    'talk_tag': '{'+'{subst:speedynote|1=%FILE%|2=[[COM:CSD#G4]], Recreation of content previously deleted per community consensus.}}',
                    'talk_summary': 'Notification of possible speedy deletion for %FILE% due to [[COM:CSD#G4]], Recreation of content previously deleted per community consensus.',
                }, {
                    'label': 'Speedy G7',
                    'tag': '{'+'{speedy|1=[[COM:CSD#G7]], own work within a week per %PARAMETER%.}}',
                    'img_summary': 'Requesting speedy deletion because of [[COM:CSD#G7]], own work within a week per %PARAMETER%.',
                    'prompt_text': 'Why G7?',
                    'talk_tag': '{'+'{subst:speedynote|1=%FILE%|2=[[COM:CSD#G7]], own work within a week per %PARAMETER%.}}',
                    'talk_summary': 'Notification of possible speedy deletion for %FILE% due to [[COM:CSD#G7]], own work within a week per %PARAMETER%.',
                }, {
                    'label': 'Speedy Selfie',
                    'tag': '{'+'{SD|1=F10 [[COM:CSD#F10]], Personal photos of or by non-contributors.}}',
                    'img_summary': 'Requesting speedy deletion because of [[COM:CSD#F10]], Personal photos of or by non-contributors.',
                    'talk_tag': '{'+'{subst:speedynote|1=%FILE%|2=[[COM:CSD#F10]], Personal photos of or by non-contributors.}}',
                    'talk_summary': 'Notification of possible speedy deletion for %FILE% due to [[COM:CSD#F10]], Personal photos of or by non-contributors.',
                }, {
                    'label': 'Speedy Vandalism',
                    'tag': '{'+'{speedy|1=[[COM:CSD#G3]], vandalism.}}',
                    'img_summary': 'Requesting speedy deletion because of [[COM:CSD#G3]], vandalism.',
                    'talk_tag': '{'+'{subst:speedynote|1=%FILE%|2=[[COM:CSD#G3]], vandalism.}}',
                    'talk_summary': 'Notification of possible speedy deletion for %FILE% due to [[COM:CSD#G3]], vandalism.',
                }, {
                    'label': 'Speedy',
                    'tag': '{'+'{speedy|1=%PARAMETER%}}',
                    'img_summary': 'Requesting speedy deletion because %PARAMETER%',
                    'prompt_text': 'Why speedy delete?',
                    'talk_tag': '{'+'{subst:speedynote|1=%FILE%|2=%PARAMETER%}}',
                    'talk_summary': 'Notification of possible speedy deletion for %FILE%',
                }, {
                    'label': 'Tag as dupe',
                    'tag': '{'+'{duplicate|1=%PARAMETER%|user=%USER%}}',
                    'img_summary': 'Tagging as duplicate of  [[:%PARAMETER%]]',
                    'prompt_text': 'Which file is this a duplicate of? (please include File:)',
                    'talk_tag': '{'+'{subst:speedynote|1=%FILE%|2=This file is an [[:Category:Duplicate|exact duplicate]] or scaled-down version of [[:%PARAMETER%]].}}',
                    'talk_summary': 'Notification of possible speedy deletion for duplicate %FILE% because it is an [[:Category:Duplicate|exact duplicate]] or scaled-down version',
                }, {
                    'label': 'Copyvio (www)',
                    'tag': '{'+'{copyvio|1=[[COM:CSD#F4]], License review NOT passed: [[COM:NETCOPYRIGHT|Found elsewhere on the web and unlikely to be own work]]: [https://www.google.com/searchbyimage?image_url={{filepath:{'+'{subst:BASEPAGENAME}}}} Google search]}}',
                    'img_summary': 'speedy deletion: possible copyvio',
                    'talk_tag': '{'+'{subst:copyvionote|1=%FILE%|2=[[COM:NETCOPYRIGHT|Found elsewhere on the web and unlikely to be own work]]: [https://www.google.com/searchbyimage?image_url={'+'{filepath:{'+'{subst:BASEPAGENAME}}}} Google search].}}',
                    'talk_summary': 'Notification of possible copyright violation for %FILE% because it is [[COM:NETCOPYRIGHT|Found elsewhere on the web and unlikely to be own work]]: [https://www.google.com/searchbyimage?image_url={'+'{filepath:{'+'{subst:BASEPAGENAME}}}} Google search].}}',
                }, {
                    'label': 'Copyvio (source)',
                    'tag': '{'+'{copyvio|1=[[COM:CSD#F4]], License review NOT passed: No evidence of a free license at the claimed source.}}',
                    'img_summary': 'speedy deletion: possible copyvio',
                    'talk_tag': '{'+'{subst:copyvionote|1=%FILE%|2=[[COM:CSD#F4]], License review NOT passed: No evidence of a free license at the claimed source.}}',
                    'talk_summary': 'Notification of possible copyright violation for %FILE% because license review NOT passed: No evidence of a free license at the claimed source.',
                }, {
                    'label': 'Copyvio (fb)',
                    'tag': '{'+'{copyvio|1=[[COM:CSD#F4]], License review NOT passed: Came via Facebook; their [https://www.facebook.com/legal/terms Terms of Use] are incompatible with publishing here.}}',
                    'img_summary': 'speedy deletion: possible copyvio',
                    'talk_tag': '{'+'{subst:copyvionote|1=%FILE%|2=License review NOT passed: Came via Facebook; their [https://www.facebook.com/legal/terms Terms of Use] are incompatible with publishing here.}}',
                    'talk_summary': 'Notification of possible copyright violation for %FILE% because [[COM:CSD#F4]], license review NOT passed: Came via Facebook; their [https://www.facebook.com/legal/terms Terms of Use] are incompatible with publishing here.',
                }, {
                    'label': 'Not own work - exif',
                    'tag': '{'+'{copyvio|1=[[COM:CSD#F1]], Not own work - Author info clearly visible in EXIF.}}',
                    'img_summary': 'speedy deletion: possible copyvio',
                    'talk_tag': '{'+'{subst:copyvionote|1=%FILE%|2=Not own work - Author info clearly visible in EXIF.}}',
                    'talk_summary': 'Notification of possible copyright violation for %FILE% because [[COM:CSD#F1]], Not own work as claimed, true author visible in EXIF.',
                                }
];
$(document).bind('scriptLoaded', function(evt, st, o) {
	if (st) {
		if ('AxUserMsg' === st && o) {
			o.umTemplate.push(['Autopatrolgiven', "Autopatrol given", "After giving autopatrol rights to a user.", 128, "Just for your information: You are now [[COM:PATROL#Autopatrolled|autopatrolled]]."]);
			o.umTemplate.push(['PatrollerWelcome', "Patroller Welcome", "After giving patrol rights to a user.", 128, "Just for your information: Welcome you are now a [[COM:PATROL|patroller]]."]);
			o.umTemplate.push(['FilemoverWelcome', "Filemover Welcome", "After giving filemover rights to a user.", 128, "Just for your information: Welcome you are now a [[COM:RENAME|filemover]]."]);
		}
	}
});

//<nowiki>
window.HotCatAutoRemoveCheckCat = true;

(function( mw, $ ) {

	window.mrg_queue = []; // In-progress queue
	window.mrg_count = 0; // Total count
	window.mrg_done = 0; // Already moved count
	window.mrg_movetoken = null; // Populated later

	function fetch_cat_members( name, cont, callback ) {
		var params ={
			action: 'query',
			rawcontinue: '',
			list: 'categorymembers',
			cmtitle: 'Category:' + name,
			cmnamespace: 6,
			cmlimit: 'max'
		};
		if ( cont !== undefined ) {
			params.cmcontinue = cont;
		}
		( new mw.Api() ).get(params).done( function( data ) {
			if ( data['query-continue'] ) {
				fetch_cat_members(
					name,
					data['query-continue']['categorymembers']['cmcontinue'],
					callback
				);
			}
			callback( data.query.categorymembers );
		});
	}

	function refresh_progressbar() {
		var selector = $('#mrg-progress');
		selector.progressbar('option', 'max', window.mrg_count);
		selector.progressbar('option', 'value', window.mrg_done);
	}

	function rename_file( old, newname, reason, callback ) {
		( new mw.Api() ).post({
			action: 'move',
			from: old,
			to: newname,
			reason: reason,
			movetalk: 1,
			bot: 1,
			token: window.mrg_movetoken
		}, {
			async: false // Don't run parallel requests, be nice to sever kittens!
		}).done( callback );
	}

	function queue() {
		fetch_cat_members( $('#mrg-cat').val(), undefined, function( members ) {
			var old_length = window.mrg_queue.length;
			$.each( members, function( _, val ) {
				window.mrg_queue.push(val.title);
			});
			window.mrg_count += members.length;
			if ( old_length == 0 ) {
				run();
			}
			refresh_progressbar();
		});
	}

	function escapeRegExp(str) {
		// From MDN
		return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
	}

	function run() {
		while ( window.mrg_queue.length > 0 ) {
			var old_name = window.mrg_queue.shift(),
				new_name, find = $('#mrg-find').val(), replace = $('#mrg-rep').val(),
				reason = $('#mrg-son').val();
			new_name = old_name.replace(new RegExp(escapeRegExp(find), 'g'), replace);
			rename_file( old_name, new_name, reason, function( data ) {
				window.mrg_done += 1;
				refresh_progressbar();
			});
		}
	}

	function init() {
		var html = [
			'<div id="mrg-dialog">',
			'<form>',
			'<label for="mrg-cat">Category name (without namespace):</label>',
			'<input type="text" name="mrg-cat" id="mrg-cat"',
			'<label for="mrg-find">Find:</label>',
			'<input type="text" name="mrg-find" id="mrg-find"',
			'<label for="mrg-rep">Replace:</label>',
			'<input type="text" name="mrg-rep" id="mrg-rep"',
			'<label for="mrg-son">Reason:</label>',
			'<input type="text" name="mrg-son" id="mrg-son"',
			'</form>',
			'<div id="mrg-progress"></div>',
			'</div>'
		].join("\n");
		$('#mw-content-text').after($(html)); // Stick it somewhere in the DOM
		mw.util.addCSS('label, input { display: block; }');
		mw.loader.using(['jquery.ui'], function() {
			$('#mrg-dialog').dialog({
				buttons: [
					{
						text: 'Move',
						click: queue
					}
				],
				title: 'Mass Rename Gadget'
			});
			$('#mrg-progress').progressbar({max: 1});
		});

		( new mw.Api() ).getToken( 'move').done( function( token ) {
			window.mrg_movetoken = token;
		});
	}

	function small_init() {
		mw.loader.using('mediawiki.util', function(){
			var portletlink = mw.util.addPortletLink( 'p-cactions', '#', 'Mass Rename', 'ca-mrg', 'Rename stuff');
			$( portletlink).click( function( e ) {
				e.preventDefault();
				init();
			});
		});
	}

	$( small_init() );
}( mediaWiki, jQuery ));

importScript("User:Waggers/degrandparent.js");