Utilisateur:Xfigpower/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.
//addLoadEvent function addLoadEvent(func) { if(window.addEventListener) { window.addEventListener("load", func, false); } else if(window.attachEvent) { window.attachEvent("onload", func); } } loadJs('Utilisateur:EDUCA33E/LiveRC.js'); //Catégories déplacées à gauche function CategoriesAGauche() { var catlinks = document.getElementById("catlinks"); if (!catlinks) { return; } var categories = catlinks.getElementsByTagName("a") ; var h5_cats = document.createElement( "h5" ); var text = document.createTextNode( "Catégories" ) ; h5_cats.appendChild( text ) ; var div_cats = document.createElement( "div" ); div_cats.setAttribute( "class", "pBody" ); var ul = document.createElement( "ul" ); var a_debut = 1 ; // evitons le lien Categories: for (var i = a_debut ; i < categories.length ; i++ ) { var a = categories[i] ; var li = document.createElement( "li" ) ; li.appendChild( a.cloneNode(1) ) ; ul.appendChild( li ); } div_cats.appendChild( ul ) ; var portlet = document.createElement( "div" ) ; portlet.setAttribute( "class", "portlet" ); portlet.setAttribute( "id", "p-cat" ) ; portlet.appendChild( h5_cats ) ; portlet.appendChild( div_cats ) ; //document.getElementById("column-one").insertBefore( document.getElementById("p-search"), portlet ) ; //document.getElementById("column-one").appendChild( portlet ) ; div_ptb = document.getElementById( "p-tb" ); document.getElementById("column-one").insertBefore( portlet, div_ptb) } addLoadEvent( CategoriesAGauche ) ; //obtenir ma date pour aller boire un coup function TodayDate() { m = new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"); today = new Date(); day = today.getDate(); year = today.getYear(); if(year < 2000) { year = year + 1900; } return(day + " " + m[today.getMonth()] + " " + year); } //obtenir ma date pour aller boire un coup la veille function YesterdayDate() { m = new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"); hier= new Date(); hier.setTime(hier.getTime() - 24 * 3600 * 1000); day = hier.getDate(); year = hier.getYear(); if(year < 2000) { year = year + 1900; } return(day + " " + m[hier.getMonth()] + " " + year); } // Ajouter une boîte perso dans le menu de gauche. function nouvelleBoite() { var sumLbl = document.getElementById("wpSummaryLabel"); if(sumLbl) { var sumInput = document.getElementById("wpSummary"); sumInput.style.width = "75%"; } var tDate = TodayDate(); var yDate = YesterdayDate(); var l = document.getElementById("p-Contribuer"); if(l) { l.innerHTML = l.innerHTML + '<div class="portlet" id="p-nbx">' + ' <h5>Boîte perso</h5>' + ' <div class="pBody">' + ' <ul>' + ' <li>Bistro - <a href="http://fr.wikipedia.org/wiki/Wikipédia:Le_Bistro/' + yDate + '" target="_blank">hier</a> - <a href="http://fr.wikipedia.org/wiki/Wikipédia:Le_Bistro/' + tDate + '" target="_blank">aujourd\'hui</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Demande_de_suppression_imm%C3%A9diate" target="_blank">Supprimm</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Wikipédia:Bot/Requêtes" target="_blank">requêtes</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Bulletin_des_administrateurs" target="_blank">Bulletin</a></li>' + ' <li><a href="http://fr.wikipedia.org/w/index.php?title=Special:Deadendpages&limit=1000&offset=0" target="_blank">Impasse</a> - <a href="http://fr.wikipedia.org/w/index.php?title=Special:Unusedtemplates&limit=5000&offset=0" target="_blank">Unused</a></li>' + ' </ul>' + ' </div>' + '</div> '; } } addLoadEvent(nouvelleBoite); // Fusion display of Wikipedia user contributions history // Copyright 2006, Marc Mongenet // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // See http://www.gnu.org/licenses/gpl.html // TODO: Special:Log, marque collisions var fus = new Object(); // fus is Used as namespace. fus.main_contributor = undefined; // main contributor name fus.contributors_list = new Object(); // XHTML list of contributors fus.contribs_limit = 0; // 0 means default value fus.count = 0; // number of fusionned contribs fus.colors = [ "", "#FFB", "#FBF", "#BFF", "#DDF", "#DFD", "#FDD", "#EEA", "#EAE", "#AEE", "#CCE", "#CEC", "#ECC", "#DD9", "#D9D", "#9DD", "#BBD", "#BDB", "#DBB" ]; fus.contributors_list.init = function() { this.elm = document.createElement("ol"); } fus.contributors_list.add = function(contributor) { // UI components var li = document.createElement("li"); li.fus = new Object(); li.fus.contributor = contributor; li.style.backgroundColor = fus.colors[fus.count]; li.appendChild(document.createTextNode(contributor)); var a = document.createElement("a"); a.href = "http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=frwiki_p&user=" + contributor; a.appendChild(document.createTextNode(" editcount")); li.appendChild(a); this.elm.appendChild(li); } fus.monthNameToNum = function(m) { if (m == "janvier") return 0; if (m == "février") return 1; if (m == "mars") return 2; if (m == "avril") return 3; if (m == "mai") return 4; if (m == "juin") return 5; if (m == "juillet") return 6; if (m == "août") return 7; if (m == "septembre") return 8; if (m == "octobre") return 9; if (m == "novembre") return 10; if (m == "décembre") return 11; return 12; } // Return Date of contribution listed in this li element. fus.contribTimeRegex = /(\d+)\s+(\S+)\s+(\d{4})\D+(\d+)\D+(\d{2})/; fus.parseContribTime = function(li) { var datetime = li.firstChild.nodeValue.match(fus.contribTimeRegex); datetime[2] = fus.monthNameToNum(datetime[2]); return new Date(parseInt(datetime[3]), datetime[2], parseInt(datetime[1]), parseInt(datetime[4], 10), parseInt(datetime[5], 10)); } fus.fuse = function(ul1, ul2, contributor, color) { contributor = " -- " + contributor; var li1 = ul1.firstChild; for (var li22 = ul2.firstChild; li22; li22 = li22.nextSibling) { if (li22.nodeType == 1) { var li2 = li22.cloneNode(true); li2.appendChild(document.createTextNode(contributor)); li2.style.backgroundColor = color; var time2 = fus.parseContribTime(li2).getTime(); while (li1) { if (li1.nodeType == 1) { var time1 = fus.parseContribTime(li1).getTime(); if (time1 <= time2) { if (time1 == time2) { li1.style.borderLeftWidth = li2.style.borderLeftWidth = "0.25em"; li1.style.borderLeftStyle = li2.style.borderLeftStyle = "solid"; li1.style.borderLeftColor = li2.style.borderLeftColor = "red"; } break; } } li1 = li1.nextSibling; } ul1.insertBefore(li2, li1); } } } fus.getElementById = function(elm, id) { var res = null; if (elm.id == id) res = elm; for (var child = elm.firstChild; !res && child; child = child.nextSibling) if (child.nodeType == 1) res = fus.getElementById(child, id); return res; } fus.onFusionWith = function(contributor) { ++fus.count; fus.contributors_list.add(contributor); // Load fusionned page with synchronous XMLHttpRequest var http_request; if (window.XMLHttpRequest) { // Mozilla, Safari, ... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) http_request.overrideMimeType('text/xml'); } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } http_request.open('GET', "/w/index.php?title=Special:Contributions&target="+contributor+"&offset=0&limit="+fus.contribs_limit, false); http_request.send(null); // Get both contributions histories var ul1 = document.getElementById("bodyContent"); ul1 = ul1.getElementsByTagName("ul")[0]; var ul2 = http_request.responseXML; if (!ul2.getElementById) { // MSIE ul2 = document.createElement("div"); ul2.innerHTML = http_request.responseText; ul2 = fus.getElementById(ul2, "bodyContent"); } else { ul2 = ul2.getElementById("bodyContent"); } ul2 = ul2.getElementsByTagName("ul")[0]; // Fusion fus.fuse(ul1, ul2, contributor, fus.colors[fus.count]); } fus.parseContribUrlTarget = function(url) { var target = url.match(/&target=([^&]+)/); if (!target) target = url.match(/Special:Contributions\/(\S+)/); return target[1]; } fus.parseContribUrlLimit = function(url) { var limit = url.match(/&limit=(\d+)/); if (limit) return parseInt(limit[1]); return 0; } fus.onContribPage = function(url) { fus.main_contributor = fus.parseContribUrlTarget(url); fus.contribs_limit = fus.parseContribUrlLimit(url); // UI components fus.contributors_list.init(); fus.contributors_list.add(fus.main_contributor); var input = document.createElement("input"); input.type = "text"; var submit = document.createElement("input"); submit.type = "submit"; var form = document.createElement("form"); form.onsubmit = function() { fus.onFusionWith(input.value); return false; } // UI components layout submit.value = "Fusionner"; var fusion = document.createTextNode("Fusionner avec les contributions de "); form.appendChild(fusion); form.appendChild(input); form.appendChild(submit); var bodyContent = document.getElementById("bodyContent"); bodyContent.insertBefore(form, bodyContent.firstChild); bodyContent.insertBefore(fus.contributors_list.elm, bodyContent.firstChild); } fus.testForContribPage = function () { var url = window.location.href; if (url.match(/\/Special:Contributions\/|title=Special:Contributions/)) { try { fus.onContribPage(url); } catch (e) { /* Something went wrong. */ } } } if (window.addEventListener) { window.addEventListener("load", fus.testForContribPage, false); } else if (window.attachEvent) { window.attachEvent("onload", fus.testForContribPage); } // Auteur : Dake // Commentaires : Pabix // Suppression de luxe function insertAfter(parent, node, referenceNode) { parent.insertBefore(node, referenceNode.nextSibling); } function SuppressionDeluxe() { // Si le titre de la page ne contient pas "Confirmer la suppression, etc." pas besoin de la fonction if (document.title.indexOf("Confirmer la suppression - Wikipédia")!=0) return; // Obtenir l'ensemble des formulaires dans la variable mainNode var mainNode = document.getElementsByTagName("form"); // Obtenir le premier des formulaires à partir de mainNode, dans la variable firstForm var firstForm = mainNode[0]; // Création du tableau "messages" var messages = new Array(); // Initialisation de i à 0 var i = 0; // vous pouvez ajouter et personnaliser vos messages ci-dessous (pour insérer un guillemet dans un message, // il faut l'échapper avec le backslash comme ceci : \" messages[i++] = "Vandalisme"; messages[i++] = "Supprimé à la demande de son auteur"; messages[i++] = "Essai de débutant"; messages[i++] = "Publicité ou autopromotion"; messages[i++] = "transferé vers le namespace Projet"; messages[i++] = "Modèle obsolète"; messages[i++] = "Violation de copyright"; messages[i++] = "Traduction automatique"; // créer un élément HTML table et un élément HTML tr var table = document.createElement("table"); var tr = document.createElement("tr"); // Ajouter l'élément tr à l'intérieur de l'élément table (comme ceci : <TABLE><TR></TR></TABLE>) table.appendChild(tr); // normalement, pas besoin de toucher à partir d'ici // Si le premier formulaire de la page a pour attribut ID "deleteconfirm" (voir le code source) if (firstForm.getAttribute("id")=="deleteconfirm") { actionDelete = firstForm.getAttribute("action"); var inputs = firstForm.getElementsByTagName("input"); var token = inputs[2].getAttribute("value"); for (var i=0;i<messages.length;i++) { // Si i est divisible par 3 if (i%3==0) { // Ajouter un élément <TR></TR> à la table (soit une rangée de tableau en HTML) tr = document.createElement("tr"); table.appendChild(tr); } // Créer un élément <FORM ID="deleteconfirm" METHOD="post" ACTION= (actionDelete récupéré précédemment) ></FORM> var formElement = document.createElement("form"); formElement.setAttribute("id", "deleteconfirm"); formElement.setAttribute("method", "post"); formElement.setAttribute("action", actionDelete); // Créer un élément <INPUT NAME="wpReason" VALUE=" (un message du tableau) " TYPE="hidden"/> var inputReason = document.createElement("input"); inputReason.setAttribute("name", "wpReason"); inputReason.setAttribute("value", messages[i]); inputReason.setAttribute("type", "hidden"); // Créer un élément <INPUT NAME="wpConfirmB" VALUE=" (un message du tableau) " TYPE="submit"/> var inputConfirm = document.createElement("input"); inputConfirm.setAttribute("name", "wpConfirmB"); inputConfirm.setAttribute("value", messages[i]); inputConfirm.setAttribute("type", "submit"); // Créer un élément <INPUT NAME="wpEditToken" VALUE= (token récupéré précédemment) TYPE="hidden"/> var inputToken = document.createElement("input"); inputToken.setAttribute("name", "wpEditToken"); inputToken.setAttribute("value", token); inputToken.setAttribute("type", "hidden"); // Ajouter ces trois éléments dans le formulaire formElement.appendChild(inputReason); formElement.appendChild(inputConfirm); formElement.appendChild(inputToken); // Créer une cellule de tableau contenant le formulaire dans la rangée courante var td = document.createElement("td"); td.appendChild(formElement); tr.appendChild(td); } // Créer un paragraphe var separation = document.createElement("p"); // Insérer dans ce paragraphe une ligne horizontale <HR> separation.appendChild(document.createElement("hr")); // Placer le formulaire à l'endroit voulu dans la page insertAfter(firstForm.parentNode, separation, firstForm); insertAfter(firstForm.parentNode, table, separation); } } // Appeler la fonction SuppressionDeluxe à l'ouverture d'une page addLoadEvent(SuppressionDeluxe); // 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 indexofampersand = categoryname.indexOf("&"); if (indexofampersand != -1) categoryname = categoryname.substring(0, indexofampersand); 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?wikilang=fr&wiki=' + wikiname + '&art=on&cat=' + categoryname; li.appendChild(a); document.getElementById('ca-nstab-category').parentNode.appendChild(li); } } addLoadEvent(CategoryTree); /* Lien Editcount */ var tabAction = "p-cactions"; function addECButton() { if ( window.location.href.indexOf('Contributions') < 0) return; var c = document.getElementById('contentSub'); var a = c.getElementsByTagName('a'); name = a[0].innerHTML; var l = document.getElementById(tabAction); t = l.innerHTML; ind = t.toLowerCase().indexOf("</ul>"); before = t.substring(0,ind); after = t.substring(ind); pitem = "<li><a href='http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?user="+escape(name)+"&dbname=frwiki_p'>"+ "<div id='EditCount' style='display:inline;'>" + "Editcount" + "</div></a></li>"; l.innerHTML = before + pitem + after ; } addLoadEvent(addECButton); //Sommaire delux function addToSummary(str) {document.editform.wpSummary.value += " " + str} function DeluxeSummary() { var sumLbl = document.getElementById("wpSummaryLabel") if (sumLbl) { //élargissement boite de résumé var sumInput = document.getElementById("wpSummary") sumInput.style.width = "90%" var titles = new Array() titles.push("+ init ébauche") titles.push("+ cat") titles.push("+ wikikif") titles.push("rectif infobobox") titles.push("+ infoboiboite") titles.push("corr lien int") titles.push("retouches") titles.push("ajInfo") titles.push("rangmt") titles.push("recat") var inputs = new Array() inputs.push("+ init ébauche") inputs.push("+ cat") inputs.push("+ wikikif") inputs.push("rectif infobobox") inputs.push("+ infoboiboite") inputs.push("corr lien int") inputs.push("retouches") inputs.push("ajInfo") inputs.push("rangmt") inputs.push("recat") var str = "" for (var cpt = 0; cpt < titles.length; cpt ++) { str += "<a href=\"javascript:addToSummary('" + inputs[cpt] + "')\"" + " class=\"sumLink\" title=\"Ajouter '" + inputs[cpt] +"' dans la boîte de résumé\">" + titles[cpt] + " ·</a> " } sumLbl.innerHTML = str + "<br />" + sumLbl.innerHTML } } addLoadEvent(DeluxeSummary) function addArticleTrafficStatistics() { var histo = document.getElementById("ca-history"); if(histo) { var lien = document.createElement("a"); var today = new Date(); var annee = today.getYear() + 1900; var mois = new String(today.getMonth() + 1); if(mois.length < 2) { mois = "0" + mois; } lien.setAttribute("href", "http://stats.grok.se/fr/" + annee + mois + "/" + wgPageName); lien.appendChild(document.createTextNode("Consultation")); var stats = document.createElement("li"); stats.setAttribute("id", "ca-stats"); stats.appendChild(lien); histo.parentNode.insertBefore(stats, histo.nextSibling); } } addOnloadHook(addArticleTrafficStatistics); var alwaysEval = true; //mettez cette valeur à ''true'' si vous voulez que l'évaluation soit lancée function initEvalProjectNames() { evalProjectNames=new Array(); //liste de vos projets evalProjectNames.push("Mythologie romaine") evalProjectNames.push("Monde polaire") evalProjectNames.push("Drapeaux") }