MediaWiki:Gadget-TemplateScript.js: Difference between revisions

MediaWiki interface page
No edit summary
No edit summary
Line 7: Line 7:
mw.config.set('userjs-templatescript', { regexEditor: false });
mw.config.set('userjs-templatescript', { regexEditor: false });
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
pathoschild.TemplateScript.add([
pathoschild.TemplateScript.add({
// add your own templates or scripts here
name:'replace -- with —',
{ name: 'welcome', template: '{{subst:welcome}} ~~~~', position: 'after', editSummary: 'welcome!', forNamespaces: 'user talk' },
script: function(editor) {
]);
editor
.replace(/--/g, '')
.appendEditSummary('replaced -- with —')
.clickDiff();
}
});
});
});
// </nowiki>
// </nowiki>

Revision as of 17:26, 12 July 2023

/**
 * 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>
mw.config.set('userjs-templatescript', { regexEditor: false });
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
pathoschild.TemplateScript.add({
	name:'replace -- with —',
	script: function(editor) {
		editor
			.replace(/--/g, '—')
			.appendEditSummary('replaced -- with —')
			.clickDiff();
	}
});
});
// </nowiki>