Jump to content

User:Gary/custom minor edits.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.
/*
	CUSTOM MINOR EDITS
	Description: Force minor edits on whichever namespaces are specificed. Can either use names or numbers, from [[Wikipedia:Namespace]].
	
	Example:
		minorEditNamespaces = ['Main', 2];
		
	The above example would set minor edits as default for the "Main" namespace (for Articles) and "2" namespace (ID number for "User").
	NOTE: "Wikipedia" namespace is "Project" in this script.
*/

if (typeof(unsafeWindow) != 'undefined')
{
	mw = unsafeWindow.mw;
}

function customMinorEdits()
{
	if (mw.config.get('wgAction') != 'edit' || typeof(minorEditNamespaces) == 'undefined' || minorEditNamespaces.length == 0) return false;
	
	var checkbox = $('#wpMinoredit');
	if (!checkbox.length) return false;
	
	if ($.inArray(mw.config.get('wgCanonicalNamespace'), minorEditNamespaces) != -1 || $.inArray(mw.config.get('wgNamespaceNumber'), minorEditNamespaces) != -1)
	{
		checkbox.attr('checked', true);
	}
}

$(document).ready(function()
{
	customMinorEdits();
});