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.
/**
 * Extra buttons in toolbar
 * @stats [[File:Krinkle_InsertWikiEditorButton.js]]
 */
// <nowiki>
if (!mw.libs.getInsertWikiEditorButton) {
  mw.libs.getInsertWikiEditorButton = $.ajax({ dataType: 'script', cache: true,
    url: 'https://meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/InsertWikiEditorButton.js&action=raw&ctype=text/javascript'
  });
}
mw.libs.getInsertWikiEditorButton.then(function () {
	// Welcome
	krInsertWikiEditorButton({
			id: 'welcome',
			icon: '//upload.wikimedia.org/wikipedia/commons/thumb/2/23/Nuvola_apps_edu_languages.svg/22px-Nuvola_apps_edu_languages.svg.png',
			label: 'Welcome',
			insertBefore: '{{Welcome}}~~~~',
			insertAfter: '',
			sampleText: '',
			autoSummary: { summary: '/* Welcome to Wikimedia Commons ! */ new section', position: 'replace' }
	});
	// [[Template:Information]]
	krInsertWikiEditorButton({
		id: 'tplinformation',
		icon: '//upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Gtk-dialog-info.svg/22px-Gtk-dialog-info.svg.png',
		label: 'File description heading and Information template',
		insertBefore: `=={{int:filedesc}}==
{{Information
|description=
|date=
|source={{Own work}}
|author=
|permission=
|other versions=
}}

=={{int:license-header}}==`,
		insertAfter: '',
		sampleText: '',
		autoSummary: { summary: 'Add [[Template:Information]]', position: 'replace' }
	});
	// Test2
	krInsertWikiEditorButton({
			id: 'test2',
			icon: '//upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Nuvola_apps_important.svg/22px-Nuvola_apps_important.svg.png',
			label: 'Test2',
			insertBefore: '{{subst:test2|',
			insertAfter: '}}~~~~',
			sampleText: '',
			autoSummary: { summary: '/* Vandalism is not appreciated */ new section', position: 'replace' }
	});
	// Test3
	krInsertWikiEditorButton({
			id: 'test3',
			icon: '//upload.wikimedia.org/wikipedia/commons/thumb/f/f1/Stop_hand_nuvola.svg/22px-Stop_hand_nuvola.svg.png',
			label: 'Test3',
			insertBefore: '{{subst:test3|',
			insertAfter: '}}~~~~',
			sampleText: '',
			autoSummary: { summary: '/* Warning for repeated vandalism */ new section', position: 'replace' }
	});
	// Hi BASEPAGENAME
	krInsertWikiEditorButton({
			id: 'mw-customeditbutton-hibasepagename',
			icon: 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/AdiumEmoticonset.png/22px-AdiumEmoticonset.png',
			label: 'Hi BASEPAGENAME',
			insertBefore: 'Hi {{subst:BASEPAGENAME}},\n',
			insertAfter: '',
			sampleText: ''
	});
	// Happy face
	krInsertWikiEditorButton({
			id: 'mw-customeditbutton-myspecialbutton',
			icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',
			label: 'Insert happy face',
			insertBefore: '[[File:Gnome-face-smile.svg|21px|',
			insertAfter: ']]',
			sampleText: 'Happy face'
	});
});
// </nowiki>


/**
 * Preview any page as a template
 *
 * Required modules: mediawiki.util
 *
 * @source https://www.mediawiki.org/wiki/Snippets/Preview_any_page_as_a_template
 * @author Jackmcbarn
 * @author Krinkle
 * @version 2010-07-10
 */
var $tplTemplate = $('#wpTemplateSandboxTemplate');
var $tplPage = $('#wpTemplateSandboxPage');
if ($tplTemplate.prop('type') === 'hidden') {
	$('#templatesandbox-editform').prepend('<legend>Preview page with this template</legend>');
	$tplTemplate
		.attr({
			type: 'text',
			size: '60',
			spellcheck: 'true'
		})
		.wrap('<label>Template name: </label>')
		.after('<br>');
	$tplPage
		.attr({
			type: 'text',
			size: '60',
			'data-mw-searchsuggest': '{"wrapAsLink":false}',
			class: 'mw-searchInput'
		})
		.wrap('<label>Page title: </label>')
		.after(' <input name="wpTemplateSandboxPreview" value="Show preview" type="submit">');
}