User:Aidan9382/scripts/defaultSummaries.js

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.
//Inspired by [[MediaWiki:Gadget-defaultsummaries.js]]
$.when( $.ready, mw.loader.using( 'oojs-ui' ) ).then( function() {
	
	var
	// <nowiki>
	moveSummaries = [
		"Correct archive indexing for simplicity and template functionality",
		"Move subpage left behind during move of parent page",
		"Standardise/fix archive name",
	],
	editSummaries = [
		"Correct archive indexing for simplicity and template functionality",
		"Merging content unreasonably split due to poor auto-archive management",
		"[[Category:Pages which use a template in place of a magic word]]",
		"Fix {{[[Template:Center|center]]}} args",
		"Do not use 2 archiving bots at once. Archives unified into one consistent format",
		"Fix [[WP:Linter|Lint]] Errors",
		"Page protection has expired",
		"Fix auto-archive location",
		"Fix excerpt target",
	];
	// </nowiki>
	
	var dropdown = new OO.ui.DropdownWidget({
		label: 'Edit summaries'
	});
	var dropdownElement = dropdown.$element[0];
	
	function addOptions(options) {
		dropdown.menu.addItems( options.map( function ( optionText ) {
			return new OO.ui.MenuOptionWidget( { label: optionText } );
		} ) );
	}
	
	var inputBox;
	if (mw.config.get("wgCanonicalSpecialPageName") == "Movepage") {
		addOptions(moveSummaries);
		dropdown.menu.on("select",function(option) {
			inputBox = document.getElementById("wpReason"); //Fetching inside the select function is intentional here
			inputBox.firstElementChild.value = option.getLabel();
		});
		dropdownElement.style = "margin-top:12px";
		var moveButton = document.getElementsByClassName("oo-ui-flaggedElement-primary")[0];
		moveButton.after(dropdownElement);
	
	} else if (document.getElementById("wpTextbox1")) {
		addOptions(editSummaries);
		inputBox = document.getElementById("wpSummary");
		minorEditBox = document.getElementById('wpMinoredit');
		dropdown.menu.on("select",function(option) {
			inputBox.value = option.getLabel();
			minorEditBox.checked = true;
		});
		dropdownElement.style = "margin-bottom:0";
		var watchDropdown = document.getElementById("mw-editpage-watchlist-expiry");
		if (watchDropdown) {
			watchDropdown.after(dropdownElement);
		}
	
	} else {
		//nothing
	}
});