User:Opencooper/templateScripts.js

/** * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor. * @see https://meta.wikimedia.org/wiki/TemplateScript * @update-token */ // License: CC0 // $.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function {	pathoschild.TemplateScript.add({ name:'collapse lists', script: function(editor) { editor .replace(/\n\n;/g, '\n;') .replace(/\n\n:/g, '\n:') .replace(/\n\n\*/g, '\n*') .appendEditSummary('Delete spaces between list items so a single list is created') .options({ minor: true, watch: true }) .clickDiff; } });	pathoschild.TemplateScript.add({ name:'\'s italics fix', script: function(editor) { editor .replace(/'s/g, "") .appendEditSummary('Use template to space italics') .options({ minor: true, watch: true }) .clickDiff; } });	pathoschild.TemplateScript.add({ name:'nihongo', script: function(editor) { editor .replace(/'(.*?) \((.*?)\)/, "'$1 ($2)") .appendEditSummary('Use template for Japanese text') .options({ minor: true, watch: true }) .clickDiff; } });	pathoschild.TemplateScript.add({ name:'curly quotes', script: function(editor) { editor .replace(/(File:[^|\n]+)“/g, "$1<<€€") .replace(/(File:[^|\n]+)”/g, "$1€€>>") .replace(/(File:[^|\n]+)‘/g, "$1<€€") .replace(/(File:[^|\n]+)’/g, "$1€€>") .replace(/“|”/g, "\"")			.replace(/‘|’/g, "'")			.replace(/<<€€/g, "“")			.replace(/€€>>/g, "”")			.replace(/<€€/g, "‘")			.replace(/€€>/g, "’")			.appendEditSummary('curly quotes to straight per MOS:CURLY')			.options({ minor: true, watch: true })			.clickDiff;	} });	pathoschild.TemplateScript.add({	name:'indentation formatting',	script: function(editor) {		editor			.appendEditSummary('Proper quote formatting')			.options({ minor: false, watch: true });	} });	pathoschild.TemplateScript.add({	name:'math indentation',	script: function(editor) {		editor			.replace(/\n:+[ \t]*/g, "\n")			.appendEditSummary('Proper indentation for accessibility')			.options({ minor: false, watch: false })			.clickDiff;	} });	pathoschild.TemplateScript.add({	name:'chem indentation',	script: function(editor) { editor .replace(/^:/g, "    ") .appendEditSummary('Proper indentation for accessibility') .options({ minor: false, watch: false }) .clickDiff; } });	pathoschild.TemplateScript.add({ name:'redundant quote marks', script: function(editor) { editor .appendEditSummary('quotation marks in a blockquote are redundant (MOS:BLOCKQUOTE)'); } });	pathoschild.TemplateScript.add({ name:'noitalquote', script: function(editor) { editor .appendEditSummary('MOS:NOITALQUOTE'); } });	pathoschild.TemplateScript.add({ name:'external links', script: function(editor) { editor .replace(/([^>])\[http.*? (.*?)\]/g, "$1$2") .appendEditSummary('external links don\'t belong in the body (WP:EXT)') .options({ minor: false, watch: false }) .clickDiff; } });	pathoschild.TemplateScript.add({ name:'lang tag', script: function(editor) { editor .appendEditSummary('use template for non-English text') .options({ minor: true, watch: false }); } }); /*	pathoschild.TemplateScript.add({ name:'nihongo errors', script: function(editor) { editor .replace(/\{\{nihongo4?\|([^|]*?)\|?\|?\|?\}\}/ig, "$1") .appendEditSummary('fix nihongo errors') .options({ minor: true, watch: false }) .clickDiff; } }); pathoschild.TemplateScript.add({ name:'nihongo2 errors', script: function(editor) { editor .replace(/\{\{nihongo(3|4)?\|/ig, "{{nihongo2|") .appendEditSummary('fix nihongo errors') .options({ minor: true, watch: false }) .clickDiff; } });	pathoschild.TemplateScript.add({ name:'see also', script: function(editor) { editor .appendEditSummary('already in body (MOS:SEEALSO)') .options({ minor: false, watch: true }); } });	pathoschild.TemplateScript.add({ name:'endash', script: function(editor) { editor .appendEditSummary('dash to endash (MOS:ENDASH)') .options({ minor: true, watch: true }); } });	pathoschild.TemplateScript.add({ name:'center tag', script: function(editor) { editor .replace(/<\/?center>/g, "") .appendEditSummary('the center tag is deprecated (WP:HTML5)') .options({ minor: true, watch: true }) .clickDiff; } });	pathoschild.TemplateScript.add({ name:'nobold', script: function(editor) { editor .replace(/'''/g, "") .appendEditSummary('MOS:NOBOLD') .options({ minor: true, watch: true }) .clickDiff; } });	pathoschild.TemplateScript.add({ name:'interlanguage', script: function(editor) { editor .replace(/\[\[:([a-z]{2}):(.*?)\|(.*?)\]\]/g, "$3") .replace(/\|([^|]+)\|lt=\1}}/g, "|$1}}") .replace(//g, "$1") .appendEditSummary('converting interlanguage links per MOS:EGG') .options({ minor: false, watch: false }) .clickDiff; } });	pathoschild.TemplateScript.add({ name:'unbulleted list', script: function(editor) { editor .replace(/(\|[^=]*=)(.*.*)/g, "$1$2") .replace(//g, " | ") .appendEditSummary('MOS:UBLIST') .options({ minor: false, watch: false }) .clickDiff; } }); }); //