Usuario:Mjoseph/monobook.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é.

/* <nowiki> */

/* Some of these tools are documented at [[User:Trilobite/Tools]]. */
/* Many are based on those employed by User:ABCD. */
/* This set-up is tailored to my monobook.css, but that shouldn't make much difference. */
/* Only tested in Firefox so far. */



/* change the names of personal tools links and the edit tab */
function changelinks() {
    if(!document.getElementById) return;
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'Talk page';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'Preferences';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'Watchlist';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'Contributions';
    document.getElementById('pt-logout').firstChild.innerHTML = 'Log out';
    if(document.getElementById('ca-edit'))
        document.getElementById('ca-edit').firstChild.innerHTML = 'edit';
}

/* this function is used to add extra tabs and links */
function addlilink(tabs, url, name, id) {
    var na = document.createElement('a');
    na.href = url;
    na.id = id;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

/* add links to the sidebar toolbox */
function addtoolboxlinks() {
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
    addlilink(tb, 'Wikipedia:Cartelera_de_acontecimientos', 'Notícias Wiki', '');
    addlilink(tb, 'http://en.wikipedia.org/wiki/User:CryptoDerk/CDVF', 'IRC Log', '');
    addlilink(tb, 'http://www.juelich.de/avatar/check-usage/', 'Comprueba uso imágen', '');
    addlilink(tb, 'http://www.wikisign.org/index.php?wsLang=es', 'Query Wikipedia', '');
    addlilink(tb, 'http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?user=&dbname=eswiki_p', 'Cuenta ediciones', '');
    addlilink(tb, 'http://tools.wikimedia.de/~interiot/cgi-bin/contribution_tree?user=&dbname=eswiki_p', 'Arbol ediciones', '');
}

/* add a purge tab */
function addpurge() {
    ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
    if(!document.getElementById) return;
    var x = document.getElementById('ca-history');
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(!x) return;
    if(x.children) x = x.children[0];
    else x = x.childNodes[0];
    addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge');
}

/* add a replace tab in edit mode */
function replace() {
    var s = prompt("Search regexp?");
    if(s) {
        var r = prompt("Replace regexp?");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "g"), r);
    }
}

/* add an unverified tab when editing image descriptions */
function unverified() {
    document.editform.wpSummary.value = 'needs a source and copyright tag - see [[Wikipedia:Image copyright tags]]';
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{unverified}}';
    txt.focus();
}
function pui() {
    document.editform.wpSummary.value = 'PUI';
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{pui}}';
    txt.focus();
}

/* add tabs to warn vandals */
function vandal(tmplt) {
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{subst:' + tmplt + '}} ~~~~~';
    txt.focus();
    txt = document.editform.wpSummary;
    txt.value = tmplt
    document.editform.wpWatchthis.checked = false;
}

/* add tabs to fill in deletion summaries */
function speedy (criterion) {
    var form = document.forms.deleteconfirm;
    form.wpReason.value = criterion;
}

/* add a tab to fill in deletion summaries with a link to VfD */
function vfddelete() {
    var form = document.forms.deleteconfirm;
    form.wpReason.value = '[[Wikipedia:Articles for deletion/' + unescape(window.location.href.replace(/^.*\?title=([^&]+)&action=delete.*$/, '$1').replace(/_/g, ' ')) + ']]';
}

/* add tabs to close VfD discussions */
function closevfd(bold, notbold) {
    var txt = document.editform.wpTextbox1;
    txt.value = "{{subst:vt}} '''" + bold + "'''" + notbold + ". ~~~~\n" + txt.value + "\n{{subst:vb}}\n";
    txt = document.editform.wpSummary;
    txt.value = "close discussion: " + bold + notbold;
    document.editform.wpWatchthis.checked = false;
}

/* add a VfD keep tab when editing talk pages */
function vfdresult() {
    document.editform.wpSummary.value = 'VfD concluded in favour of keeping';
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '==Articles for deletion==\nIn July 2005, this article was nominated for deletion. The result was to keep. See [[Wikipedia:Articles for deletion/{{subst:PAGENAME}}]] for a record of the discussion. ~~~~';
    txt.focus();
}

/* add tabs to show and hide closed VfD discussions on log pages */
function hidevfd() {
    var divs = document.getElementsByTagName("div");
    for(var x = 0; x < divs.length; ++x)
        if(divs[x].className.indexOf("vfd") != -1)
            divs[x].style.display = "none";
    document.getElementById('footer').style.display = 'none';
}
function showvfd() {
    var divs = document.getElementsByTagName("div");
    for(var x = 0; x < divs.length; ++x)
        if(divs[x].className.indexOf("vfd") != -1)
            divs[x].style.display = "";
    document.getElementById('footer').style.display = '';
}

/* add a tab linking to VfD for deleted pages */
function vfdold () {
    var x = document.getElementById('ca-article');
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(!x) return;
    if(x.children) x = x.children[0];
    else x = x.childNodes[0];
    addlilink(tabs, x.href.replace(/Special:Undelete/, "Wikipedia:Articles_for_deletion"), 'vfd', '');
}

/* check what kind of page you're viewing and add tabs approriately */
function morelinks() {
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(document.title.indexOf("Editing ") == 0) addlilink(tabs, 'javascript:replace()', 'replace', '');
    if(document.title.indexOf("Editing Image:") == 0) {
        addlilink(tabs, 'javascript:unverified()', 'tag', '');
        addlilink(tabs, 'javascript:pui()', 'pui', '');
    }
    if(document.title.indexOf("Editing User talk:") == 0) {
        addlilink(tabs, 'javascript:vandal("test")', '1', '');
        addlilink(tabs, 'javascript:vandal("test2")', '2', '');
        addlilink(tabs, 'javascript:vandal("test2a")', '2a', '');
        addlilink(tabs, 'javascript:vandal("test3")', '3', '');
        addlilink(tabs, 'javascript:vandal("test4")', '4', '');
        addlilink(tabs, 'javascript:vandal("test5")', '5', '');
        addlilink(tabs, 'javascript:vandal("spam")', 's1', '');
        addlilink(tabs, 'javascript:vandal("spam2")', 's2', '');
        addlilink(tabs, 'javascript:vandal("spam3")', 's3', '');
        addlilink(tabs, 'javascript:vandal("spam4")', 's4', '');
    }
    if(document.title.indexOf("Confirm delete - Delete") == 0) {
        addlilink(tabs, 'javascript:speedy("nonsense")', 'no', '');
        addlilink(tabs, 'javascript:speedy("remove redirect for page move")', 're', '');
        addlilink(tabs, 'javascript:speedy("misleading redirect")', 'mr', '');
        addlilink(tabs, 'javascript:speedy("talk page with no useful history")', 'tu', '');
        addlilink(tabs, 'javascript:speedy("talk page of deleted article")', 'td', '');
        addlilink(tabs, 'javascript:vfddelete()', 'vfd', '');
    }
    if(document.title.indexOf("Editing Wikipedia:Articles for deletion") == 0) {
        addlilink(tabs, 'javascript:closevfd("delete", "")', 'D', '');
        addlilink(tabs, 'javascript:closevfd("keep", "")', 'K', '');
        addlilink(tabs, 'javascript:closevfd("merge and redirect", " to [[" + prompt("Merge and redirect to?") + "]]")', 'M', '');
        addlilink(tabs, 'javascript:closevfd(prompt("Result?"), "")', 'O', '');
        addlilink(tabs, 'javascript:closevfd("redirect", " to [[" + prompt("Redirect to?") + "]]")', 'R', '');
        addlilink(tabs, 'javascript:closevfd("speedy delete", "")', 'S', '');
        addlilink(tabs, 'javascript:closevfd("transwiki", " to " + prompt("Transwiki to?"))', 'T', '');
    }
    if(document.title.indexOf("Editing Talk:") == 0) addlilink(tabs, 'javascript:vfdresult()', 'vfd', '');
    if(document.title.indexOf("Wikipedia:Articles for deletion/Log") == 0) {
        addlilink(tabs, 'javascript:hidevfd()', 'h', 'ca-hide');
        addlilink(tabs, 'javascript:showvfd()', 's', 'ca-show');
    }
    if(document.title.indexOf("View and restore deleted pages") == 0) vfdold();
}



/* Live Preview by User:Pilaf */
wpUserName = 'Mjoseph';
wpShowImages = true;
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js&action=raw&ctype=text/javascript'); 



//From User:JesseW/monobook.js
function addSinceTab() {
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
       do_since_I_last_edited()
    }
    else if (!/wiki\/Special:|w\/index.php?title=Special:/.test(window.location.href)) {
       var thetitle=document.title.slice(0, String(document.title).indexOf(" - "));
       var l=addlilink(tabs, "/w/index.php?title="+thetitle+"&action=history&gotosince=true", 'since', '');
       l.lastChild.title="Changes since I last edited";
    }
}
function do_since_I_last_edited() {
	var csub=document.getElementById("contentSub");
	var msg=document.createElement("p");
	msg.appendChild(document.createTextNode
			("Parsing history... please wait..."));
	msg.className="error";
	csub.insertBefore(msg, csub.firstChild)

	var username=document.getElementById("pt-userpage").textContent;
	var hists=document.getElementById("pagehistory").childNodes;
	for (n=0;n<hists.length;n++) {
	    if (hists[n].getElementsByTagName("span")[0].textContent==username) {
		document.location=hists[n].childNodes[1].href; 
		return;
	    }
	}

	msg.replaceChild(document.createTextNode
			 ("You have not edited this page! (recently)"),
			 msg.firstChild);
}



/* Go! */
window.onload = Main;
function Main() {
    changelinks();
    addtoolboxlinks()
    addpurge();
    addSinceTab();
    morelinks();
    LivePreviewInstall();
}

/* </nowiki> */
/* [[User:Pilaf/livepreview.js]] */

// [[User:Lupin/popups.js]]

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');