User:Xbony2/common/autosummary.js

/** * Does a few things: * - Creates a default summary of "created page" when without a provided summary for new pages. * - Adds a default summary for general edits that can be configured right from the editor. Saved via cookies. * * @author User:Xbony2 * @author User:Chocohead (for new page fix) * Original code poked these a little bit: * - wikipedia:Wikipedia:WikiProject User scripts/Scripts/Force edit summary * - https://habbo.gamepedia.com/User:Developaws/common.js * */ function getDefaultSummary{ var summary = ''; decodeURIComponent(document.cookie).split(';').forEach(function(cookie){		var regex = /default_summary=(.+)/.exec(cookie);		if(regex !== null){			summary = regex[1];			return summary;		}	}); return summary; }

mw.loader.using('oojs-ui-core').done(function{	var defaultSummaryInput = new OO.ui.TextInputWidget({ value: getDefaultSummary, id: 'wpDefaultSummary', name: 'wpDefaultSummary', maxlength: '200', tabindex: 1, size: 60, spellcheck: 'true', title: 'Default summary:' });	defaultSummaryInput.on('change', function{ //Maybe this could be escaped, but nah document.cookie = "default_summary=" + $('input[name=wpDefaultSummary]').val + ";path=/"; });	var defaultSummaryInputField = new OO.ui.FieldLayout(defaultSummaryInput, { label: new OO.ui.HtmlSnippet('Enter a default summary'), align: 'top', id: 'wpDefaultSummaryLabel', classes: ['mw-default-summary'] });	$('#wpSummaryLabel').after(defaultSummaryInputField.$element); }); $('input[name=wpSave]').click(function{	if($('input[name=wpSummary]').val === '')		$('input[name=wpSummary]').val(mw.config.get('wgArticleId') === 0 ? 'created page' : getDefaultSummary); });