User:GorillaWarfare/script/curlies.js

From Wikipedia, the free encyclopedia
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.
 // This script replaces curly quotes (“”‘’) with straight quotes ("') per the
 // guidance at [[MOS:CURLY]].
 
 /**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see https://meta.wikimedia.org/wiki/TemplateScript
 * @update-token [[File:Pathoschild/templatescript.js]]
 */
// <nowiki>	
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
	pathoschild.TemplateScript.add([
		{
			name: 'Curlies',
			script: function(editor) {
				editor
					.replace(/[“”]/g, '"')
					.replace(/[‘’]/g, "'")
					.options({ minor: true })
					.appendEditSummary("replaced curly quotes (“”‘’) with straight quotes (\"') per [[MOS:CURLY]], by [[User:GorillaWarfare/script/curlies.js|script]]")
					.clickDiff();
			}
		},
	]);
});
// </nowiki>