Usuario:Jsanchezes/monobook.js
Apariencia
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é.
//<nowiki>
//------------------------------------------------
// [[Usuario:Jsanchezes/monobook.js]]
//
// Para más detalles véase [[Wikipedia:Botonera]]
//------------------------------------------------
/*********** Botonera ***********/
window.onload = loadButtons;
function loadButtons()
{
if (window.opener!=undefined && window.opener.document.title=='JMSE') {
var direccion = window.location.pathname;
pos = direccion.indexOf('/wiki.phtml');
if (pos>0) {
anade_texto();
} else {
window.close();
}
}
var buttons = '<div>';
/* Botón Cambios */
buttons += '<a class="mybutton" title="Añade texto" href="javascript:cambia_enlaces()" style="background:red" ><code style="background:red">C</code></a>';
buttons += '<a class="mybutton" title="Terminar" href="javascript:terminar()" style="background:green" ><code style="background:green">T</code></a>';
buttons += '</div>';
var toolbox = document.getElementById("p-nav");
toolbox.innerHTML += '<h5>Mi botonera</h5>'+buttons;
}
function trim(cadena)
{
var pos = 0;
var fin = 0;
for(pos=0; cadena.charAt(pos)==' ';pos++);
for(fin=cadena.length-1; cadena.charAt(fin)==' ';fin--);
if (fin >= pos) {
return cadena.substring(pos,fin+1);
}
return '';
}
var ventanas = new Array();
var tout;
var indice = 0;
var indice_limite = 0;
var contador = 0;
var paginas = new Array();
paginas[0] = '301';
paginas[1] = '302';
paginas[2] = '303';
paginas[3] = '304';
paginas[4] = '305';
paginas[5] = '306';
paginas[6] = '307';
paginas[7] = '308';
paginas[8] = '309';
paginas[9] = '310';
function cambia_lista_paginas()
{
if (indice < paginas.length) {
document.title='JMSE';
ventanas[indice] = open('http://es.wikipedia.org/w/wiki.phtml?title='+paginas[indice]+'&action=edit', 'Nueva_'+indice, '');
indice += 1;
tout = setTimeout("cambia_lista_paginas()",10000);
}
}
function cambia_anios()
{
if (indice < indice_limite) {
document.title='JMSE';
ventanas[indice] = open('http://es.wikipedia.org/w/wiki.phtml?title='+indice+' adC&action=edit', 'Nueva_'+indice, '');
indice += 1;
tout = setTimeout("cambia_anios()",10000);
}
}
var tabla='';
var posicion=0;
var fila='';
var articulo='';
var propuesta='';
var discusion='';
var articulo_final = '';
var a_borrar_de_lista = '';
function lee_tabla()
{
var pos;
var fin;
if (tabla == '') {
pos = document.editform.wpTextbox1.value.indexOf('\n{|');
if(pos < 0) return;
fin = document.editform.wpTextbox1.value.indexOf('\n|}', pos+3);
if(fin < 0 ) return;
tabla = document.editform.wpTextbox1.value.substring(pos+1,fin+2);
}
}
function primera_fila()
{
var pos;
var fin;
var articulo_inicial = '';
fila='';
lee_tabla();
if (tabla == '') return;
pos = document.editform.wpTextbox1.value.indexOf('[[articulo_inicial:');
if (pos < 0) return;
fin = document.editform.wpTextbox1.value.indexOf(']]', pos+2);
if (fin < 0) return;
articulo_inicial = document.editform.wpTextbox1.value.substring(pos+19,fin);
pos = document.editform.wpTextbox1.value.indexOf('[[articulo_final:');
if (pos < 0) return;
fin = document.editform.wpTextbox1.value.indexOf(']]', pos+2);
if (fin < 0) return;
articulo_final = document.editform.wpTextbox1.value.substring(pos+17,fin);
pos = tabla.indexOf('[['+articulo_inicial+']]');
if (pos < 0) return;
fin = tabla.indexOf('\n|', pos+2);
if(fin < 0) return;
fila = tabla.substring(pos, fin);
}
function siguiente_fila()
{
var pos;
var fin;
articulo='';
propuesta='';
discusion='';
lee_tabla();
if (tabla == '') {fila = ''; return;}
if (fila == '') {
primera_fila();
if (fila == '') return;
} else {
pos = tabla.indexOf(fila);
if(pos < 0) {fila = ''; return;}
fila = '';
pos = tabla.indexOf('\n|-', pos);
if(pos < 0) return;
pos = tabla.indexOf('\n|', pos+2);
if(pos < 0) return;
fin = tabla.indexOf('\n|', pos+2);
if(fin < 0) return;
fila = tabla.substring(pos+2, fin);
}
pos = fila.indexOf('||');
if (pos < 0) {
articulo = fila;
} else {
articulo = fila.substring(0,pos);
fin = fila.indexOf('||', pos+2);
if (fin < 0) {
propuesta = trim(fila.substring(pos+2));
} else {
propuesta = trim(fila.substring(pos+2, fin));
discusion = trim(fila.substring(fin+2));
}
}
pos = articulo.indexOf('[[');
if (pos < 0) {fila = ''; articulo=''; propuesta=''; discusion=''; return;}
fin = articulo.indexOf(']]', pos+2);
if (fin < 0) {fila = ''; articulo=''; propuesta=''; discusion=''; return;}
articulo = trim(articulo.substring(pos+2, fin));
}
function cambia_enlaces()
{
if (fila == '') {
siguiente_fila();
}
if (fila=='' || articulo=='' || propuesta=='' || discusion!='') {fila=''; articulo=''; propuesta=''; discusion=''; return;}
document.title='JMSE';
ventanas[indice] = open('http://es.wikipedia.org/w/wiki.phtml?title='+ escape(articulo) +'&action=edit&categoria='+ escape(propuesta) +'&', 'Nueva_'+indice, '');
if (articulo == articulo_final) {
alert('FIN');
return;
}
var anterior = articulo;
propuesta = '';
while (fila!='' && articulo!='' && articulo!=articulo_final && (propuesta=='' || discusion!='')) {
siguiente_fila();
}
if (fila!='' && articulo!='' && articulo!=anterior && propuesta!='' && discusion=='') {
indice += 1;
tout = setTimeout("cambia_enlaces()",10000);
} else {
alert('FIN');
}
}
function terminar()
{
var pos;
var inicio;
var fin;
var cambios = 0;
var articulo;
document.title='Cambios terminados';
clearTimeout(tout);
if (a_borrar_de_lista == '') {
alert('Sin cambios');
return;
}
var texto = document.editform.wpTextbox1.value;
var tmp;
pos = a_borrar_de_lista.indexOf('[[');
while (pos >= 0) {
fin = a_borrar_de_lista.indexOf(']]', pos+2);
if (fin < 0) return;
articulo = a_borrar_de_lista.substring(pos, fin+2);
inicio = texto.indexOf(articulo);
if (inicio < 0) return;
fin = texto.indexOf('\n|', inicio);
if (fin < 0) return;
inicio = texto.lastIndexOf('\n|-', inicio);
if (inicio < 0) return;
tmp = texto.substring(0,inicio)+texto.substring(fin);
texto = tmp;
cambios += 1;
pos = a_borrar_de_lista.indexOf('[[', pos+2);
}
if (cambios > 0) {
document.editform.wpTextbox1.value = texto;
}
alert('Cambios= '+cambios);
}
function sustituye(cadena)
{
var car_especiales = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜßàáâãäåæçèéêëìíîïòóôõöùúûüÿ_';
var car_sustitutos = 'AAAAAAACEEEEIIIIOOOOOUUUUBaaaaaaaceeeeiiiiooooouuuuy ';
var resultado = '';
var pos;
for (i=0;i<cadena.length;i++) {
pos = car_especiales.indexOf(cadena.charAt(i));
if (pos < 0) {
resultado += cadena.charAt(i);
} else {
resultado += car_sustitutos.charAt(pos);
}
}
return resultado;
}
var direccion = '';
var titulo = '';
var categorias = '';
var pos_categoria = 0;
var categoria = '';
var cambiar = '';
var por = '';
var borrar = '';
var orden = '';
var cambios = 0;
var sumario = '';
var error = false;
function busca_cat(cat,categoria)
{
var categoria_upper;
var categoria_lower;
var categoria_u_sub;
var categoria_l_sub;
var texto;
var pos;
var inicio;
var fin;
categoria = trim(categoria);
categoria_u_sub = categoria;
pos = categoria.indexOf(' ');
while (pos >= 0) {
categoria_u_sub = categoria_u_sub.substring(0,pos)+'_'+categoria.substring(pos+1);
pos = categoria.indexOf(' ', pos+1);
}
categoria_upper = categoria.substring(0,1);
categoria_upper = categoria_upper.toUpperCase();
categoria_lower = categoria_upper.toLowerCase();
categoria_l_sub = categoria_lower + categoria_u_sub.substring(1);
categoria_u_sub = categoria_upper + categoria_u_sub.substring(1);
categoria_upper = categoria_upper + categoria.substring(1);
categoria_lower = categoria_lower + categoria.substring(1);
texto = document.editform.wpTextbox1.value;
pos = texto.indexOf('[['+cat+':');
while(pos >= 0) {
inicio = texto.indexOf(':', pos+2);
fin = texto.indexOf(']]', pos+2);
if (fin < 0) return -1;
encontrada = trim(texto.substring(inicio+1, fin));
if (encontrada=='') return -1;
fin = encontrada.indexOf('|');
if(fin > 0) {
encontrada = trim(encontrada.substring(0,fin));
}
if(encontrada == categoria_upper || encontrada == categoria_lower || encontrada == categoria_u_sub || encontrada == categoria_l_sub) {
return pos;
}
pos = texto.indexOf('[['+cat+':', pos+2);
}
return -1;
}
function busca_categoria(categoria)
{
var pos;
pos = busca_cat('Categoría',categoria);
if (pos < 0) {
pos = busca_cat('categoría',categoria);
if (pos < 0) {
pos = busca_cat('Category',categoria);
if (pos < 0) {
pos = busca_cat('category',categoria);
if (pos < 0) {
return -1;
}
}
}
}
return pos;
}
function pagina_titulo()
{
titulo = '';
var pos = direccion.indexOf('?title=');
if (pos < 0) return;
var fin = direccion.indexOf('&',pos+7);
if (fin < 0) return;
titulo = direccion.substring(pos+7,fin);
}
function url_categorias()
{
categorias = '';
var pos = direccion.indexOf('&categoria=');
if (pos < 0) return;
var fin = direccion.indexOf('&',pos+2);
if (fin < 0) return;
categorias = direccion.substring(pos+11,fin);
}
function lee_categoria()
{
categoria = cambiar = por = borrar = orden = '';
if (pos_categoria >= categorias.length) return;
pos_categoria = categorias.indexOf('[[:Categoría:', pos_categoria);
if (pos_categoria < 0) return;
pos_categoria += 13;
var fin = categorias.indexOf(']]', pos_categoria);
if (fin < 0) {alert('Sin cierre de Categoría en entrada'); error = true; return;}
categoria = trim(categorias.substring(pos_categoria, fin));
var inicio = categoria.indexOf('#');
if (inicio < 0) return;
var resto = trim(categoria.substring(inicio+1));
categoria = trim(categoria.substring(0, inicio));
fin = resto.indexOf(':Borrar:');
if (fin >= 0) {
borrar = categoria;
return;
}
fin = resto.indexOf(':Cambiar:');
if (fin >= 0) {
cambiar = categoria;
return;
}
fin = resto.indexOf(':Por:');
if (fin >= 0) {
por = categoria;
}
inicio = resto.indexOf(':Orden:');
if (inicio >= 0) {
fin = resto.indexOf('#', inicio+7);
if (fin < 0) {
orden = trim(resto.substring(inicio+7));
} else {
orden = trim(resto.substring(inicio+7, fin));
}
if (orden.charAt(orden.length - 1) == ':') {
var numero = parseInt(orden.substring(0, orden.length - 1));
orden = '';
if (!isNaN(numero) && numero > 1) {
var pos;
var blanco = ' ';
pos = titulo.indexOf(blanco);
if (pos < 0) {
blanco = '_';
pos = titulo.indexOf(blanco);
if (pos < 0) {
blanco = '';
}
}
if (blanco != '') {
pos = -1;
for (i=0; i < numero-1; i++) {
pos = titulo.indexOf(blanco, pos+1);
if (pos < 0) break;
}
if (pos > 0) {
orden = titulo.substring(pos+1) + ', ' + titulo.substring(0, pos);
}
}
}
if (!isNaN(numero) && numero == 1) {
orden = titulo;
}
}
if (orden != '') {
orden = sustituye(orden);
orden = '|'+trim(orden);
}
}
}
function anade_categoria()
{
var pos;
var fin;
var txtarea = document.editform.wpTextbox1;
if (categoria+'nulo'!='nulo') {
pos = busca_categoria(categoria);
if (pos < 0) {
txtarea.value += '\n[[Categoría: '+ categoria + orden +']]\n';
cambios += 1;
sumario += ', Añadida "' + categoria + '"';
} else {
if (orden != '') {
fin = txtarea.value.indexOf(']]', pos+2);
if (fin < 0) {alert('Sin cierre de Categoría en texto'); error = true; return;}
var tmp = txtarea.value + ' ';
txtarea.value = tmp.substring(0,pos) + '\n[[Categoría: '+ categoria + orden +']]\n' + tmp.substring(fin+2);
cambios += 1;
sumario += ', Cambiado orden a "' + categoria + '"';
}
}
}
}
function borrar_categoria()
{
var pos;
var fin;
var txtarea = document.editform.wpTextbox1;
if (borrar+'nulo'!='nulo') {
pos = busca_categoria(borrar);
if (pos >= 0) {
fin = txtarea.value.indexOf(']]', pos+2);
if (fin < 0) {alert('Sin cierre de Categoría en texto'); error = true; return;}
var tmp = txtarea.value + ' ';
txtarea.value = tmp.substring(0,pos) + tmp.substring(fin+2);
cambios += 1;
sumario += ', Borrada "' + borrar + '"';
}
}
}
function cambiar_categoria(anterior)
{
var pos;
var fin;
var txtarea = document.editform.wpTextbox1;
if (anterior+'nulo'!='nulo' && por+'nulo'!='nulo') {
pos = busca_categoria(anterior);
fin = busca_categoria(por);
if (pos >= 0 && fin < 0) {
fin = txtarea.value.indexOf(']]', pos+2);
if (fin < 0) {alert('Sin cierre de Categoría en texto'); error = true; return;}
if (orden == '') {
var barra = txtarea.value.indexOf('|', pos+2);
if (barra >= 0 && barra < fin) {
orden = txtarea.value.substring(barra, fin);
}
}
var tmp = txtarea.value + ' ';
txtarea.value = tmp.substring(0,pos) + '\n[[Categoría: '+ por + orden +']]\n' + tmp.substring(fin+2);
cambios += 1;
sumario += ', Cambiada "' + anterior +'" por "' + por + '"';
}
if (pos < 0 && fin < 0) {
txtarea.value += '\n[[Categoría: '+ por + orden +']]\n';
cambios += 1;
sumario += ', Añadida "' + por + '"';
}
}
}
function anade_texto()
{
/* Categorías dadas en url */
direccion = unescape(document.location.search);
titulo = categorias = '';
pagina_titulo();
url_categorias();
if (titulo == '' || categorias == '') {alert('Sin datos de entrada'); return;}
var txtarea = document.editform.wpTextbox1;
if (txtarea.value+'nulo' == 'nulo') {
window.opener.a_borrar_de_lista += '[['+titulo+']]';
window.close();
}
if (txtarea.value.indexOf('REDIRECT') >= 0) {alert('Página redireccionada'); return;}
cambios = 0;
sumario = '';
var anterior = '';
lee_categoria();
while(categoria != '' && error == false) {
if (borrar != '') {
borrar_categoria();
} else {
if (cambiar != '') {
anterior = cambiar;
lee_categoria();
if (por == '') {alert('Sin Categoría :Por:'); return;}
cambiar_categoria(anterior);
} else {
anade_categoria();
}
}
lee_categoria();
}
if (error == true) return;
window.opener.a_borrar_de_lista += '[['+titulo+']]';
if(cambios > 0) {
window.opener.contador += 1;
document.editform.wpSummary.value = 'Categorías: '+ sumario.substring(2);
document.editform.wpMinoredit.checked = true;
document.editform.submit();
} else {
window.close();
}
}
/*********** Fin botonera ************/
//</nowiki>