Usuario:Metrónomo/common.js

De Wikipedia, la enciclopedia libre

Nota: Después de guardar, debes refrescar la caché de tu navegador para ver los cambios. Internet Explorer: mantén presionada Ctrl mientras pulsas Actualizar. Firefox: mientras presionas Mayús pulsas el botón Actualizar, (o presiona Ctrl-Shift-R). Los usuarios de Google Chrome y Safari pueden simplemente pulsar el botón Recargar. Para más detalles e instrucciones acerca de otros exploradores, véase Ayuda:Cómo limpiar la caché.

/**
 * 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:'Desenlazar años',
	script: function(editor) {
		editor
			.replace(/\[\[((\d*?)(\s?[Dd]e\s)?([Ee]nero|[Ff]ebrero|[Mm]arzo|[Aa]bril|[Mm]ayo|[Jj]unio|[Jj]ulio|[Aa]gosto|[Ss]ep?tiembre|[Oo]ctubre|[Nn]oviembre|[Dd]iciembre)?(\s?[Dd]e\s)?(\d*?))\]\]/g, '$1')
			.appendEditSummary('')
			.clickDiff();
	}
});

pathoschild.TemplateScript.add({
	name:'Traducido de',
//	forNamespaces:'talk',
	script: function(editor) {
		editor
			.replace(/https:\/\/(.+)\.wikipedia.*?title=(.+)&oldid=(\d+)/g, '{{Traducido de|$1|$2||$3}}')
			.replace(/_/g, " ")
			.replace(/%27/g, "'")
			.replace(/%C3%A0/g, "à")
			.appendEditSummary('{{Traducido de}}')
			.clickPreview();
	}
});

/*
pathoschild.TemplateScript.add({
	name:'Redirección',
	script: function(editor) {
		editor
			.prepend( "#REDIRECCIÓN [[Radical {{sust:#switch:{{sust:PAGENAME}}|一=1|丨=2|丶=3|丿=4|乙|⺄|乚=5|亅=6|二=7|亠=8|人|亻|𠆢=9|儿=10|入=11|八=12|冂=13|冖=14|冫=15|几=16|凵=17|刀|刂=18|力=19|勹=20|匕=21|匚=22|匸=23|十=24|卜=25|卩|㔾=26|厂=27|厶=28|又=29|口=30|囗=31|土=32|士=33|夂=34|夊=35|夕=36|大=37|女=38|子=39|宀=40|寸=41|小|⺌|⺍=42|尢|尣=43|尸=44|屮=45|山=46|巛|川|巜=47|工=48|己=49|巾=50|干=51|幺=52|广=53|廴=54|廾=55|弋=56|弓=57|彐|彑=58|彡=59|彳=60|心|忄|⺗=61|戈=62|戶|户|戸=63|手|扌|龵=64|支=65|攴|攵=66|文=67|斗=68|斤=69|方=70|无|旡=71|日=72|曰=73|月=74|木=75|欠=76|止=77|歹|歺=78|殳=79|毋|母|⺟=80|比=81|毛=82|氏=83|气=84|水|氺|氵=85|火|灬=86|爪|爫=87|父=88|爻=89|爿|丬=90|片=91|牙=92|牛|牜|⺧=93|犬|犭=94|玄=95|玉|玊|王|⺩=96|瓜=97|瓦=98|甘=99|生=100|用=101|田=102|疋|⺪=103|疒=104|癶=105|白=106|皮=107|皿=108|目=109|矛=110|矢=111|石=112|示|礻=113|禸=114|禾=115|穴=116|立=117|竹|⺮=118|米=119|糸|糹=120|缶=121|网|罒|⺲|罓|⺳=122|羊|⺶|⺷=123|羽=124|老|耂=125|而=126|耒=127|耳=128|聿|⺻=129|肉|⺼=130|臣=131|自=132|至=133|臼=134|舌=135|舛=136|舟=137|艮=138|色=139|艸|艹=140|虍=141|虫=142|血=143|行=144|衣|衤=145|襾|西|覀=146|見=147|角=148|言|訁=149|谷=150|豆=151|豕=152|豸=153|貝=154|赤=155|走|赱=156|足|⻊=157|身=158|車=159|辛=160|辰=161|辵|辶|⻌|⻍=162|邑|阝|⻏|⻖=163|酉=164|釆=165|里=166|金|釒=167|長|镸=168|門=169|阜|阝=170|隶=171|隹=172|雨=173|青|靑=174|非=175|面|靣=176|革=177|韋=178|韭=179|音=180|頁=181|風|𠘨=182|飛=183|食|飠=184|首=185|香=186|馬=187|骨=188|高|髙=189|髟=190|鬥=191|鬯=192|鬲=193|鬼=194|魚=195|鳥=196|鹵=197|鹿=198|麥=199|麻=200|黃=201|黍=202|黑=203|黹=204|黽=205|鼎=206|鼓=207|鼠=208|鼻=209|齊=210|齒=211|龍=212|龜=213|龠=214}}]]" )
			.appendEditSummary('Creo redirección')

            $( '#editform' ).submit();
	}
});
*/

pathoschild.TemplateScript.add({
	name:'Plantilla NF',
	script: function(editor) {
		editor
			.replace(/\[\[((\d*?)(\s?[Dd]e\s)?([Ee]nero|[Ff]ebrero|[Mm]arzo|[Aa]bril|[Mm]ayo|[Jj]unio|[Jj]ulio|[Aa]gosto|[Ss]ep?tiembre|[Oo]ctubre|[Nn]oviembre|[Dd]iciembre)?(\s?[Dd]e\s)?(\d*?))\]\]/g, '$1')
			.replace(/\{\{(NF|BD|DEFAULTSORT|ORDENAR|control de autoridades).*?\}\}\n/gi, '')
			.replace(/(\n)+(\[\[categoría:(.|\n)*?)?\[\[categoría:nacidos en (\d*?)\]\]\n(.|\n)*?\[\[categoría:fallecidos en (\d*?)\]\]\n/gi, "$1$1{{NF|$4|$6{{sust:#ifeq:{{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=^[^%s]*%s*|replace=|plain=false}} | {{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=.*%s|replace=|plain=false}} | {{sust:!}}{{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=.*%s|replace=|plain=false}}, {{sust:#invoke:String|match|s= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |^[^%s]*}} | }}}}$1$2$5")
			.replace(/(\n)+(\[\[categoría:(.|\n)*?)?\[\[categoría:nacidos en (\d*?)\]\]\n/gi, "$1$1{{NF|$4|{{sust:#ifeq:{{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=^[^%s]*%s*|replace=|plain=false}} | {{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=.*%s|replace=|plain=false}} | {{sust:!}}{{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=.*%s|replace=|plain=false}}, {{sust:#invoke:String|match|s= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |^[^%s]*}} | }}}}$1$2")
			.replace(/(\n)+(\[\[categoría:(.|\n)*?)?\[\[categoría:fallecidos en (\d*?)\]\]\n(.|\n)*?\[\[categoría:nacidos en (\d*?)\]\]\n/gi, "$1$1{{NF|$6|$4{{sust:#ifeq:{{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=^[^%s]*%s*|replace=|plain=false}} | {{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=.*%s|replace=|plain=false}} | {{sust:!}}{{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=.*%s|replace=|plain=false}}, {{sust:#invoke:String|match|s= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |^[^%s]*}} | }}}}$1$2$5")
			.replace(/(\n)+(\[\[categoría:(.|\n)*?)?\[\[categoría:fallecidos en (\d*?)\]\]\n/gi, "$1$1{{NF||$4{{sust:#ifeq:{{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=^[^%s]*%s*|replace=|plain=false}} | {{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=.*%s|replace=|plain=false}} | {{sust:!}}{{sust:#invoke:String|replace|source= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |pattern=.*%s|replace=|plain=false}}, {{sust:#invoke:String|match|s= {{sust:#Invoke:String|replace|{{sust:PAGENAME}}|%s%(.*%)||plain=false}} |^[^%s]*}} | }}}}$1$2")
			.replace(/\[\[categoría:(hombres|mujeres)\]\]\n/gi, '')
			.appendEditSummary('Reemplazo categorías manuales por la [[Plantilla:NF]]')
			.clickDiff();
	}
});

pathoschild.TemplateScript.add({
	name:'Cita publicación',
	script: function(editor) {
		editor
			.replace(/qwerty/g, '{{Cita publicación |apellidos1= |nombres1= |apellidos2= |nombres2= |apellidos3= |nombres3= |apellidos4= |nombres4= |apellidos5= |nombres5= |título= |publicación= |volumen= |número= |páginas= |fecha= |editorial= |issn= |doi= |idioma=inglés}}')
	}
});


//pathoschild.TemplateScript.add([
//                { name: 'Bienvenida', template: '{{subst:Bienvenido usuario}} ~~~~', position: 'after', editSummary: 'Bienvenido a Wikipedia en español', forNamespaces: 'user talk' }
//        ]);


});
// </nowiki>