Utilisateur:Fabrice Ferrer/monobook.js
Un article de Wikipédia, l'encyclopédie libre.
Note : Après avoir sauvegardé, vous devez forcer le rechargement de la page pour voir les changements : Mozilla / Konqueror / Firefox : Shift-Ctrl-R, IE / Opera : Ctrl-F5, Safari : Cmd-R.
function DeluxeBar() { if (document.createTextNode) { var toolbar = document.getElementById("toolbar"); if (!toolbar) return; ///// zone personnalisable //// var messages = new Array() // le texte a été splitté sinon Mediawiki casse tout... messages[0] = "{{subst:" + "Bienvenue sur ta page" + "}}" + "~~" + "~~"; messages[1] = "{{subst:" + "Bienvenue" + "}}" + "~~" + "~~"; messages[2] = "{{subst:" + "Bienvenue débutant" + "}}" + "~~" + "~~"; messages[3] = "{{subst:" + "Bienvenue vandale" + "}}" + "~~" + "~~"; messages[4] = "{{subst:" + "test1" + "}}" + "~~" + "~~"; messages[5] = "{{subst:" + "test2" + "}}" + "~~" + "~~"; messages[6] = "{{subst:" + "test3" + "}}" + "~~" + "~~"; messages[7] = "{{subst:" + "Bienvenue spammeur" + "}}" + "~~" + "~~"; messages[8] = "{{subst:" + "Bienvenue autopromo" + "}}" + "~~" + "~~"; messages[9] = "{{subst:" + "Bienvenue copyvio " + "}} " + "~~" + "~~"; messages[10] = "{{" + "copie de site|URL|Titre" + "}}"; messages[11] = "{{" + "suppression" + "}}"; messages[12] = "{{" + "multi bandeau|portail Les Royaumes Oubliés|portail fantasy" + "}}"; messages[13] = "{{" + "Conserver" + "}} " + "~~" + "~~"; messages[14] = "{{" + "Supprimer" + "}} "+ "~~" + "~~"; var images = new Array() images[0] = "http://upload.wikimedia.org/wikipedia/fr/1/12/Button_accueilA.png"; images[1] = "http://upload.wikimedia.org/wikipedia/fr/e/eb/Button_accueilB.png"; images[2] = "http://upload.wikimedia.org/wikipedia/fr/a/ad/Button_vandale2.png"; images[3] = "http://upload.wikimedia.org/wikipedia/fr/a/ad/Button_vandale2.png"; images[4] = "http://upload.wikimedia.org/wikipedia/fr/0/00/Button_vandale.png"; images[5] = "http://upload.wikimedia.org/wikipedia/fr/0/00/Button_vandale.png"; images[6] = "http://upload.wikimedia.org/wikipedia/fr/0/00/Button_vandale.png"; images[7] = "http://upload.wikimedia.org/wikipedia/fr/f/fb/Button_spam2.png"; images[8] = "http://upload.wikimedia.org/wikipedia/fr/f/fb/Button_spam2.png"; images[9] = "http://upload.wikimedia.org/wikipedia/fr/6/67/Button_%C3%A9clair.png"; images[10] = "http://upload.wikimedia.org/wikipedia/fr/e/e5/Button_copyvio.png"; images[11] = "http://upload.wikimedia.org/wikipedia/fr/f/f8/Button_suppr.png"; images[12] = "http://upload.wikimedia.org/wikipedia/fr/2/20/Bouton_Portail.png" images[13] = "http://upload.wikimedia.org/wikipedia/fr/a/ae/Button_trait%C3%A9conserver.png"; images[14] = "http://upload.wikimedia.org/wikipedia/fr/9/96/Button_trait%C3%A9supprimer.png"; var commentaires = new Array() commentaires[0] = "Bienvenue sur ta page!"; commentaires[1] = "Bienvenue!" commentaires[2] = "Bienvenue, débutant" commentaires[3] = "Bienvenue, vandale" commentaires[4] = "Avertissement vandalisme" commentaires[5] = "Avertissement vandalisme" commentaires[6] = "Dernier avertissement (vandalisme)" commentaires[7] = "Avertissement spam" commentaires[8] = "Avertissement Autopromotion" commentaires[9] = "Avertissement Copyvio" commentaires[10] = "Violation de copyright" commentaires[11] = "Page proposée à la suppression" commentaires[12] = "Ajout du bandeau {{multi bandeau|portail Les Royaumes Oubliés|portail fantasy}}" commentaires[13] = "Mon avis: Conserver" commentaires[14] = "Mon avis: Supprimer" //////////////////////////////// for (var i=0;i<messages.length;i++) { var img = document.createElement("img"); img.setAttribute("src", images[i]); var ref = document.createElement("a"); ref.setAttribute("href", "javascript:insertTags('', \"" + messages[i] + "\", '');" + "javascript:changeSummary(\"" + commentaires[i] + "\");" ); ref.appendChild(img); toolbar.appendChild(ref); } } } function changeSummary(sampleText) { document.editform.wpSummary.value = sampleText; } addLoadEvent(DeluxeBar); ////////////////////////////////// function addLoadEvent(func) { if (window.addEventListener) window.addEventListener("load", func, false); else if (window.attachEvent) window.attachEvent("onload", func); } function nouvelOnglet() { var a = document.getElementById("p-cactions"); if (a) { b = a.getElementsByTagName("ul"); if(b.length > 0) { b[0].innerHTML = b[0].innerHTML + '<li id="ca-nstab-user">' + '<a href="/wiki/Utilisateur:Fabrice Ferrer/Bacasable">' + 'Ma Test Zone</a></li>'; } } } addLoadEvent(nouvelOnglet); //////////////////////// //<pre><nowiki> /* 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); //</nowiki></pre> function addPurgeButton() { // condition à améliorer var s = window.location.search; if (s.indexOf("?") == -1) { 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='javascript:purgePage();'>"+ "<div id='purgeTab' style='display:inline;'>" + "Purger" + "</div></a></li>"; l.innerHTML = before + pitem + after ; } } function purgePage() { window.location.search = '?action=purge'; } addLoadEvent(addPurgeButton); //<pre><nowiki> /* * Résumé Deluxe * * Ajoute des commentaires de modification prédéfinis * * Auteur : Dake * Contributions : Pabix, Tieno * Date de dernière révision : 12 novembre 2006 */ //////////////////////ZONE PERSONNALISABLE////////////////////// var resumedeluxeTitles = new Array(); with (resumedeluxeTitles) { push("Corrections orthographiques"); push("- Corrections typographiques"); push("- Catégorisation"); push("- Interwiki"); push("- Wikification"); push("- Image"); push("- Création de la redirection"); push("- Révocation"); push("- Ebauche RO"); } var resumedeluxeInputs= new Array(); with (resumedeluxeInputs) { push("Corrections orthographiques"); push("Corrections typographiques"); push("Catégorisation"); push("Interwiki"); push("Wikification"); push("Image"); push("Création de la redirection"); push("Révocation"); push("Ajout du bandeau: {{ebauche RO}}"); } /////////////////FIN DE LA ZONE PERSONNALISABLE///////////////// function setSummary(str) { document.editform.wpSummary.value = str; } function addToSummary(str) { var resum = document.editform.wpSummary.value; if(resum != 0 && resum.indexOf("*/") < resum.length - 3) { document.editform.wpSummary.value += " - "; } document.editform.wpSummary.value += str; } function DeluxeSummary() { var sumLbl = document.getElementById("wpSummaryLabel"); if(sumLbl) { var sumInput = document.getElementById("wpSummary"); sumInput.style.width = "95%"; var str = "Messages prédéfinis : "; for(var cpt = 0; cpt < resumedeluxeTitles.length; cpt ++) { str += "<a href=\"javascript:addToSummary('" +resumedeluxeInputs[cpt] + "')\"" + " class=\"sumLink\" title=\"Ajouter '" +resumedeluxeInputs[cpt] +"' dans la boîte de résumé\">" + resumedeluxeTitles[cpt] + "</a> "; } sumLbl.innerHTML = str + "<br />" + sumLbl.innerHTML; } } addLoadEvent(DeluxeSummary); //</nowiki></pre>[[Catégorie:MediaWiki:Fonction Monobook en JavaScript]] //<pre><nowiki> /* * Outils pour réverter * * Fournit des liens dans les pages de diff * * Auteur : Lorian (en) * Dernière révision : 3 novembre 2006 */ function getElementsByClass(searchClass,node,tag) { // Function from http://www.dustindiaz.com/getelementsbyclass/ var classElements = new Array(); if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } } return classElements; } // _GET code from NoGray JS Library http://www.nogray.com/new_site/ var _GET = new Array(); var _uri = location.href; var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&"); var _temp_get_arr_1 = new Array(); for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){ _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("="); _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]); } delete _uri; delete _temp_get_arr; delete _temp_get_arr_1; function getMessage (where, user1, user2) { var message = prompt ('Quel message faut-il laisser ?', ''); if (message) { window.location = 'http://fr.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message; } } addOnloadHook(function (){ if (location.href.match(/diff=/)) { // Get username of submitter var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML; var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[2].innerHTML; if (user2 == "défaire"){ user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML; } document.getElementById('contentSub').innerHTML = '(<a href="http://fr.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">Annuler</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">Message</a>) (<a href="http://fr.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">Vandalisme</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">Message</a>) (Avertir : <a href="http://fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=1">Test0</a> / <a href="http://fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=2">Test1</a> / <a href="http://fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=3">Test2</a> / <a href="http://fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=4">Test3</a>)'; } else if (location.href.match(/revert=1/)) { document.getElementById('wpSummary').value = 'Révocation des modifications par [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] ; retour à la version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]'; document.getElementById('editform').submit(); } else if (location.href.match(/revert=2/)) { document.getElementById('wpSummary').value = 'Révocation des modifications par [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] ; retour à la version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')'; document.getElementById('editform').submit(); } else if (location.href.match(/vandalism=1/)) { document.getElementById('wpSummary').value = 'Révocation de vandalisme par [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] ; retour à la version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]'; document.getElementById('editform').submit(); } else if (location.href.match(/vandalism=2/)) { document.getElementById('wpSummary').value = 'Révocation de vandalisme par [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] ; retour à la version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')'; document.getElementById('editform').submit(); } else if (location.href.match(/warn=1/)) { document.getElementById('wpSummary').value = 'Bienvenue, débutant'; document.getElementById('wpTextbox1').value = '{{sub'+'st:test0}} ~~'+'~~'; document.getElementById('editform').submit(); } else if (location.href.match(/warn=2/)) { document.getElementById('wpSummary').value = 'Avertissement vandalisme'; document.getElementById('wpTextbox1').value = '{{sub'+'st:test1}} ~~'+'~~'; document.getElementById('editform').submit(); } else if (location.href.match(/warn=3/)) { document.getElementById('wpSummary').value = 'Avertissement vandalisme'; document.getElementById('wpTextbox1').value = '{{sub'+'st:test2}} ~~'+'~~'; document.getElementById('editform').submit(); } else if (location.href.match(/warn=4/)) { document.getElementById('wpSummary').value = 'Avertissement vandalisme'; document.getElementById('wpTextbox1').value = '{{sub'+'st:test3}} ~~'+'~~'; document.getElementById('editform').submit(); } else if (location.href.match(/warn=5/)) { document.getElementById('wpSummary').value = 'Avertissement spam'; document.getElementById('wpTextbox1').value = '{{Bienvenue spammeur}} ~~'+'~~'; document.getElementById('editform').submit(); } }); //</nowiki></pre>[[Catégorie:MediaWiki:Fonction Monobook en JavaScript]] obtenir("OptimizedSuivi"); obtenir("EditZeroth"); obtenir("BistroDuJour"); 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); loadJs('Utilisateur:EDUCA33E/LiveRC.js'); function addLoadEvent(func) { if (window.addEventListener) { window.addEventListener("load", func, false); } else if (window.attachEvent) { window.attachEvent("onload", func); } } function nouvelleBoite() { var l = document.getElementById("column-one"); if (l) { l.innerHTML = l.innerHTML + '<div class="portlet" id="p-nbx">' + ' <h5>Suivi</h5>' + ' <div class="pBody">' + ' <ul>' + ' <li><a href="http://fr.wikipedia.org/wiki/Special:Recentchangeslinked/Utilisateur:Fabrice_Ferrer/Suivre-Vandalisme">Vandalisme</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Special:Recentchangeslinked/Utilisateur:Fabrice_Ferrer/Suivre-Articles">Encyclopédie</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Special:Recentchangeslinked/Catégorie:Donjons et Dragons">D&D</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Special:Recentchangeslinked/Catégorie:Les_Royaumes_Oubliés">Royaumes Oubliés</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Special:Recentchangeslinked/Catégorie:Nightwish">Nightwish</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Special:Recentchangeslinked/Catégorie:Queen (groupe)">Queen</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Special:Recentchangeslinked/Catégorie:Linux">Linux</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Special:Recentchangeslinked/Utilisateur:Fabrice_Ferrer/Namespace Wikipedia">Namespace Wikipedia</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Special:Recentchangeslinked/Utilisateur:Fabrice_Ferrer/Suivre-Utilisateurs">Utilisateurs</a></li>' + ' </ul>' + ' </div>' + '</div> '; } } addLoadEvent(nouvelleBoite); function addLoadEvent(func) { if (window.addEventListener) { window.addEventListener("load", func, false); } else if (window.attachEvent) { window.attachEvent("onload", func); } } function nouvelleBoite2() { var l = document.getElementById("column-one"); if (l) { l.innerHTML = l.innerHTML + '<div class="portlet" id="p-nbx">' + ' <h5>Outils</h5>' + ' <div class="pBody">' + ' <ul>' + ' <li><a href="http://fr.wikipedia.org/wiki/Wikipédia:Pages à supprimer">Pages à supprimer</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Wikipédia:Demande de suppression immédiate">Suppression immédiate</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Wikipédia:Annonces">Annonces</a></li>' + ' <li><a href="http://fr.wikipedia.org/wiki/Special:Mypage/monobook.js">Monobook.js</a></li>' + ' </ul>' + ' </div>' + '</div> '; } } addLoadEvent(nouvelleBoite2);