Utilisateur:Reyman/monobook.js

Un article de Wikipédia, l'encyclopédie libre.

Note : Après avoir publié la page, vous devrez forcer son rechargement pour voir les changements : Mozilla / Konqueror / Firefox : Shift-Ctrl-R, Internet Explorer / Opera : Ctrl-F5, Safari : Cmd-R.

function OptimizedNavig() 
{
  var a = document.getElementById("p-navigation");
 
  if (a) 
  {
    b = a.getElementsByTagName("ul");
    if(b.length > 0)
    { 
      var startUrl = '/w/index.php?title='
      var endUrl = '&action=purge'
 
      // liste des URLs
      var urls = new Array()
      urls[0] = 'Wikipédia:Le Bistro'
      urls[1] = 'Wikipédia:Pages à supprimer'
      urls[2] = 'Wikipédia:Proposition articles de qualité'
      urls[3] = 'Special:Newpages'
 
 
      var labels = new Array()
      labels[0] = 'Bistro'
      labels[1] = 'PàS'
      labels[2] = 'pAdQ'
      labels[3] = 'newPage'
 
 
      for (var i=0;i<urls.length;i+=2) {
        tableHTML = '<table valign="top" cellspacing="0" cellpadding="0">'
        tableHTML += '<tr>'
        tableHTML += '<li><td><a href="' + startUrl + urls[i] + endUrl + '">' + labels[i] + ' | </a></td>'
        tableHTML += '<td><a href="' + startUrl + urls[i+1] + endUrl + '">' + labels[i+1] + '</a></td></li>'
        tableHTML += '</tr>'
        tableHTML += '</table>' 
        b[0].innerHTML = b[0].innerHTML + tableHTML
      }
 
    }
  }
}
 
 
addLoadEvent(OptimizedNavig);
 
function insertAfter(parent, node, referenceNode) {
    parent.insertBefore(node, referenceNode.nextSibling);
}
 
function OptimizedSuivi() 
{
        if (document.URL.indexOf("http://fr.wikipedia.org/wiki/Special:Watchlist")==0 ||
        document.URL.indexOf("http://fr.wikipedia.org/w/index.php?title=Special:Watchlist")==0 ){
 
                var allDays = document.getElementsByTagName("ul");
 
                for (i=0; i<allDays.length; i++) {
                        if (allDays[i].getAttribute("class") == "special") {
 
                                var artList = allDays[i].getElementsByTagName("li");
                                for (j=0; j<artList.length; j++) {
                                        var elem = artList[j];
                                        var aTag = elem.getElementsByTagName("a");
                                        var articleName = aTag[0].getAttribute("title");
                                        var stopWatch  = "/w/index.php?title=" + articleName + "&action=unwatch"
 
                                        var newElement = document.createElement("a");
                                        newElement.setAttribute("href",stopWatch);
                                        var newText = document.createTextNode("stop");
                                        newElement.appendChild(newText);
 
                                        var newPar = document.createTextNode(") (")
                                        // séparation des cas (nouvel article, ou déjà existant)
                                        if (aTag[0].childNodes[0].data == "diff") {
                                                insertAfter(elem, newPar, aTag[1]); 
                                        } else {
                                                insertAfter(elem, newPar, aTag[0]); 
                                        }
 
                                        insertAfter(elem, newElement, newPar);
                                }       
                        }
                }
        }
}
 
addLoadEvent(OptimizedSuivi);
 
//------------------------------------------------------------------------------------------DeluxeBar
// Merki Dake :P
// Ajoute des boutons dans la barre d'édition
function DeluxeBar()
{
	if (document.createTextNode)
	{
		var toolbar = document.getElementById("toolbar")
		if (!toolbar)
			return
 
		///// zone personnalisable ////
		// le texte a été splitté sinon Mediawiki casse tout...
		// Accueil nouveau
		var img = document.createElement("img")
		img.setAttribute("src", "http://upload.wikimedia.org/wikipedia/fr/e/eb/Button_accueilB.png")
		var ref = document.createElement("a")
		ref.setAttribute("href", "javascript:insertTags('', \"" + "{{subst:" + "Bienvenue" + "}}" +  "Bonjour et bienvenue parmi nous ;) ~~" + "~~" + "\", '');" + "setSummary(\"" + "Bienvenue !" + "\");" );
		ref.setAttribute("title", "Ajouter le modèle d'accueil des nouveaux")
		ref.appendChild(img)
		toolbar.appendChild(ref)
 
		// Accueil vandale
		img = document.createElement("img")
		img.setAttribute("src", "http://upload.wikimedia.org/wikipedia/fr/6/62/Button_stop.png")
		ref = document.createElement("a")
		ref.setAttribute("href", "javascript:insertTags('', \"" + "{{subst:" + "Bienvenue vandale" + "}}" + "~~" + "~~" + "\", '');" + "setSummary(\"" + "Bienvenue..." + "\");" )
		ref.setAttribute("title", "Ajouter le modèle d'accueil des vandales")
		ref.appendChild(img);
		toolbar.appendChild(ref);
 
		// Blanchiement
		img = document.createElement("img")
		img.setAttribute("src", "http://upload.wikimedia.org/wikipedia/fr/f/f8/Button_suppr.png")
		ref = document.createElement("a")
		ref.setAttribute("href", "javascript:setSummary('blanchi, contenait: ' + document.getElementById('wpTextbox1').value);setTextarea('')")
		ref.setAttribute("title", "Blanchir")
		ref.appendChild(img)
		toolbar.appendChild(ref)
 
		// Signature
		img = document.createElement("img")
		img.setAttribute("src", "http://upload.wikimedia.org/wikipedia/fr/e/e5/Button_copyvio.png")
		ref = document.createElement("a")
		ref.setAttribute("href", "javascript:insertTags('', \"" + "~~" + "~~" + "\", '');")
		ref.setAttribute("title", "Ajouter la signature")
		ref.appendChild(img)
 
		toolbar.appendChild(ref)
	}
}
 
function setSummary(str)
{
	document.editform.wpSummary.value = str
}
 
function setTextarea (str)
{
	document.editform.wpTextbox1.value = str
}
addLoadEvent(DeluxeBar)
 
// Modification de l'onglet Google de Dake par GôTô
function getArticleName()
{
        var strOut = document.title
        // case search
        if (strOut == "Rechercher - Wikipédia")
                return document.getElementById("lsearchbox").value
        // case article being modified
        strOut = strOut.replace("modification de ", "").replace(" - Modifier", "")
 
        strOut = strOut.replace(" - Wikipédia", "")
        return strOut
}
 
var whichWiki = "en"
function setWiki()
{
        var newWiki = document.getElementById("elmtWhichWiki").value
        // trim
        newWiki = newWiki.replace(/ /g, "")
        // no need to change
        if (newWiki == whichWiki)
                return
        var elmt = document.getElementById("whichW")
        // it was a wikipedia and now it's a wikimedia (commons or meta)
        if (/commons?|m(e|é){1}ta/.test(newWiki) && !(/commons?|m(e|é){1}ta/.test(whichWiki)))
        {
                elmt.href = elmt.href.replace(".wikipedia.org", ".wikimedia.org")
                elmt.title = elmt.title.replace(".wikipedia.org", ".wikimedia.org")
        }
        // it was a wikimedia (commons or meta) and now it's a wikipedia
        else if (/commons?|m(e|é){1}ta/.test(whichWiki) && !(/commons?|m(e|é){1}ta/.test(newWiki)))
        {
                elmt.href = elmt.href.replace(".wikimedia.org", ".wikipedia.org")
                elmt.title = elmt.title.replace(".wikimedia.org", ".wikipedia.org")
        }
        // in any case
        elmt.href = elmt.href.replace("http://" + whichWiki, "http://" + newWiki)
        elmt.title = elmt.title.replace("sur " + whichWiki, "sur " + newWiki)
        whichWiki = newWiki
}
 
function searchLinks()
{
        var site = (/commons?|m(e|é){1}ta/.test(whichWiki) ? 'wikimedia' : 'wikipedia')
        var a = document.getElementById("p-cactions")
        if (a)
        {
                var pageName = getArticleName()
                var ulElmt = a.getElementsByTagName("ul")
 
                if(ulElmt.length > 0)
                {
                        ulElmt[0].innerHTML += '<li><a id="whichW" onmousedown="setWiki()" onkeydown="setWiki()" href="http://' + whichWiki + '.' + site + '.org/wiki/Special:Search?search=' + pageName + '" title="Rechercher ' + pageName + '">'
                        + 'Recherche wp</a>'
                        + '<input type=text id="elmtWhichWiki" style="color : #002bb8; font: normal 8pt Arial; text-align: top; border: 0px; background: none; width: 50px" maxlength="7" value="' + whichWiki + '">'
                        + '<span style="color: #002bb8; font-weight: bold; padding-left: 0.5em; background: none">G:</span>'
                        + '<a href="http://www.google.fr/search?num=20&hl=en&safe=off&q=site%3Afr.wikipedia.org+' + pageName + '&btnG=Search" title="Rechercher sur Google dans fr.wikipédia.org">'
                        + 'wp-fr</a>'
                        + '<a href="http://www.google.fr/search?num=20&hl=en&safe=off&q=site%3Awikipedia.org+' + pageName + '&btnG=Search" title="Rechercher sur Google dans wikipédia.org">'
                        + 'wp</a>'
                        + '<a href="http://www.google.fr/search?num=20&hl=fr&safe=off&q=' + pageName + '&btnG=Search&meta=lr%3Dlang_fr" title="Rechercher sur Google dans tout le web en français">'
                        + 'web-fr</a>'
                        + '<a href="http://www.google.fr/search?num=20&hl=en&safe=off&q=' + pageName + '&btnG=Search" title="Rechercher sur Google dans tout le web">'
                        + 'web</a>'
                        + '</li>'
                }
        }
} 
addLoadEvent(searchLinks)
 
function startSearch()
{
  var textsearch = document.getElementById('searchInput').value;
 
  var link = "http://vs.aka-online.de/cgi-bin/globalwpsearch.pl?search=";
  link = link + textsearch;
  link = link + "&timeout=120&minor=1";
 
  window.location = link;
}
 
function globalSearch()
{
  var pSearchElement = document.getElementById('searchform');
 
  var newElement = document.createElement("input");
  newElement.setAttribute("type", "button");
  newElement.setAttribute("name", "globalsearch");
  newElement.setAttribute("class", "searchButton");
  newElement.setAttribute("value", "Recherche globale");
  newElement.setAttribute("onClick", "startSearch()");
 
  pSearchElement.appendChild(newElement);
}
addLoadEvent(globalSearch);
 
// Auteur : Anakin
// Dernière mise à jour : 11 décembre 2005
function CategoryTree()
{
  var element = document.getElementById('ca-nstab-category');
  if (element)
  {
    var categoryname = element.firstChild.href;
    categoryname = categoryname.substring(7);
 
    var wikiname = categoryname.substring(0, categoryname.indexOf('.'));
 
    var indexofname = categoryname.indexOf(":") + 1;
    categoryname = categoryname.substring(indexofname);
 
    var indexofampercent = categoryname.indexOf("&");
    if (indexofampercent != -1)
      categoryname = categoryname.substring(0, indexofampercent);
 
    var li = document.createElement('li');
    li.id = 'ca-categorytree';
 
    var a = document.createElement('a');
    a.appendChild(document.createTextNode("Arborescence"));
    a.href = 'http://tools.wikimedia.de/~daniel/WikiSense/CategoryTree.php?wiki=' + wikiname + '&art=on&cat=' + categoryname;
 
    li.appendChild(a);
 
    document.getElementById('ca-nstab-category').parentNode.appendChild(li);
  }
}
addLoadEvent(CategoryTree);
 
function ResumeDeluxeModif(content) {
  // codé par Dake que je remercie !
  if (document.editform.wpSummary.value != 0) {
    document.editform.wpSummary.value+=' - ';
  }
  document.editform.wpSummary.value+=content;
}
function ResumeDeluxe() {
  // codé par Dake que je remercie !
 
  /* Les trois lignes suivantes permettent de ne pas montrer les 
   * boutons de remplissage lorsqu'il s'agit d'une nouvelle
   * section
   */
  if (document.title.indexOf("modification de")!=0) return;
  if (document.title.indexOf("(commentaire) - Wikipédia") == document.title.length - 25) return;
  if (document.title.indexOf("(commentaire) - Prévisualiser - Wikipédia") == document.title.length - 41) return;
  var messages = new Array()
 
  // Ligne 1 de boutons
 
  messages[0] = "Ortho";
  messages[1] = "Typo";
  messages[2] = "+";
  messages[3] = "+ liens";
  messages[4] = "pchimie";
  messages[5] = "pphysique";
 
  // Ligne 2 de boutons
 
  messages[6] = "forme";
  messages[7] = "Avertissement";
  messages[8] = "Notification de blocage";
  messages[9] = "Vote";
  messages[10] = "homonymie";
  messages[11] = "Argumentation";
 
  var messages2 = new Array()
 
  // Ligne 1 de commentaires
 
  messages2[0] = "orth";
  messages2[1] = "typo";
  messages2[2] = "précisions";
  messages2[3] = "liens";
  messages2[4] = "portail chimie";
  messages2[5] = "portail physique";
 
  // Ligne 2 de commentaires
 
  messages2[6] = "mise en forme";
  messages2[7] = "Avertissement suite à un vandalisme";
  messages2[8] = "Notification de blocage d’un contributeur";
  messages2[9] = "A voté !";
  messages2[10] = "Correction des [[Wikipédia:Projet/Liens vers les pages d’homonymie|liens vers les pages d’homonymie]]";
  messages2[11] = "J’argumente ma position";
 
  var nombreBoutonsParLigne = 6;
 
  var mainNode = document.getElementById("wpSummaryLabel");
  if (!mainNode) return;
  var summaryNode = mainNode;
  var formButtons = document.createElement("form");
  for (var i=0;i<messages.length;i++) {
    if (i%nombreBoutonsParLigne==0) {
      formButtons.appendChild(document.createElement("p"));
    }
    var nodeInput = document.createElement("input");
    nodeInput.setAttribute("type", "button"); 
    nodeInput.setAttribute("value", messages[i]); 
    nodeInput.setAttribute("onClick", "ResumeDeluxeModif('" + messages2[i] + "')"); 
    formButtons.appendChild(nodeInput); 
  }
  summaryNode.appendChild(formButtons);
}
addLoadEvent(ResumeDeluxe);