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.
//  Fix sports medals to not use templates with bad sorting.
//
//  Testing page is at [[User:MikeVitale/scripts/medals.js/tests]].
//  Please report false positives on the talk page.

// <nowiki>
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
	pathoschild.TemplateScript.add([{
		name: 'Medal Fixer',
		script: function(editor) {
			// Do replacements
			editor.replace(/{{goca}}/gi, `{{gold1}}`);
			editor.replace(/{{gold01}}/gi, `{{gold1}}`);

			editor.replace(/{{sica}}/gi, `{{silver2}}`);
			editor.replace(/{{silver02}}/gi, `{{silver2}}`);

			editor.replace(/{{brca}}/gi, `{{bronze3}}`);
			editor.replace(/{{bronze03}}/gi, `{{bronze3}}`);

			// Options
			editor
				.options({ minor: true })
				.appendEditSummary("Fixed sports medals using [[User:MikeVitale/scripts/medals.js]]")
				.clickDiff();
		}
	}]);
});
// </nowiki>