Utilisateur:Bot de Sept Lieues/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.
/* <pre><nowiki> */ //cookies document.write('<script type="text/javascript" src="' + 'http://fr.wikipedia.org/w/index.php?title=Utilisateur:GôTô/objects.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); /* ****************************************** */ /* EDUCA33E : 23/03/06 */ /* Fonction de remplacement automatisé */ /* à partir des pages search et Whatlinkshere */ /* et Catégorie (lettre par lettre) */ /* ATTENTION : */ /* Enregistrement automatique du remplacement */ /* ****************************************** */ function ORTHOPatrol() { if ( window.location.href.indexOf('Search') < 0 && window.location.href.indexOf('Special:Whatlinkshere') < 0 && window.location.href.indexOf('Cat%C3%A9gorie:') < 0) return; var r = prompt("ORTHO : Chaîne à remplacer (expression régulière) ?"); // exemple (A|a)cb(d|e) var s = prompt("ORTHO : À remplacer par ?"); // exemple $1bc$2 // d'où de part l'exemple : // Acbd => Abcd // acbd => abcd // Acbe => Abce // acbe => abce var page_nom = document.getElementById( 'content' ).getElementsByTagName( 'h1' )[ 0 ]; var page_name = page_nom.firstChild.nodeValue; var items, item, i, links, user, name, talk, contribs, insertLoc, link; items = document.getElementById( 'bodyContent' ).getElementsByTagName( 'ul' )[ 0 ].getElementsByTagName( 'li' ); function NewLink( txt, url, plainlinks, linkColor ) { var a = document.createElement( 'a' ); a.appendChild( document.createTextNode( txt ) ); a.href = url; if ( plainlinks ) a.className = 'plainlinks'; if ( linkColor ) { if ( typeof linkColor == "string" ) a.style.color = linkColor; else a.style.color = '#FF0000'; // old default behavior } return a; } for ( i = 0; i < items.length; i++ ) { item = items[ i ]; links = item.getElementsByTagName( 'a' ); user = links[ 0 ]; name = user.firstChild.nodeValue; insertLoc = user.nextSibling; // ' newusers ' item.insertBefore( document.createTextNode( ' [' ), insertLoc ); item.insertBefore( NewLink( 's:/'+r+'/'+s+'/', '/w/index.php?title='+name+'&action=edit&or1='+escape(r)+'&or2='+escape(s), true, 'blue' ), insertLoc ); item.insertBefore( document.createTextNode( '] ' ), insertLoc ); } } if ( window.addEventListener ) window.addEventListener( 'load', ORTHOPatrol, false ); else if ( window.attachEvent ) window.attachEvent( 'onload', ORTHOPatrol ); // Récupération des paramètres passés par url. function TJSExtraireParam() { url = window.location.href; var exp=new RegExp("[&?]+","g"); var exp2=new RegExp("[=]+","g"); var tabNom=url.split(exp); var tabParam=new Array(); if (tabNom!=null) { for (var i=1;i<tabNom.length;i++){ var tabTemp=tabNom[i].split(exp2); tabParam[tabTemp[0]]=unescape(tabTemp[1]); } } return tabParam; } // Remplacement de texte r pour s. // s = expression régulière. function replaceortho(s,r){ var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "gi"), r); } function changeSummary(sampleText) { document.editform.wpSummary.value = sampleText; } // Récupération des paramètres d'URL pour remplacement function autoSaveOrtho() { try { var title = decodeURI(window.location.href.split("title=")[1].split("&action=")[0]).replace(/\s/g, "_") } catch (e) { var title = decodeURI(window.location.href.split("/wiki/")[1]).replace(/\s/g, "_") } if ( window.location.href.indexOf('or1=') >= 0 ) { if (!document.getElementById("toolbar")) return; var urlParam = TJSExtraireParam(); replaceortho(urlParam["or1"],urlParam["or2"]); changeSummary('correction orthographique semi-automatique s:/'+urlParam["or1"]+'/'+urlParam["or2"]+'/'); //un ptit cookie pour revenir (hmmmmmm c'est bon les cookies !) cookies.set("autoSaveOrtho", (cookies.get("autoSaveOrtho") ? cookies.get("autoSaveOrtho") : "") + "|*" + title + "*|") document.editform.submit(); } else if (cookies.get("autoSaveOrtho").indexOf("|*" + title + "*|") > -1) { //on corrige le cookie pour pas revenir 2 fois cookies.set("autoSaveOrtho", cookies.get("autoSaveOrtho").replace("|*" + title + "*|", "")); window.location.href = "/w/index.php?title=" + title + "&diff=cur"; } } addLoadEvent(autoSaveOrtho); function lastdiff() { 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="/w/index.php?title=' + getArticleName() + '&diff=cur">' + 'Diff</a></li>'; } } } addLoadEvent(lastdiff); 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(" - Prévisualiser", "") strOut = strOut.replace(" - Wikipédia", "") return strOut } function searchLink() { var div = document.getElementById("p-search") if (div) div = div.getElementsByTagName("div")[0]; if (div) { var input = document.getElementById("searchInput") if (input.addEventListener) input.addEventListener("keyup", setSearchLink, false); else if (input.attachEvent) input.attachEvent("onkeyup", setSearchLink); var a = document.createElement("a"); a.setAttribute("href", "/wiki/Special:Search?search=&fulltext=Search&offset=0&limit=500") a.innerHTML = "full search" a.id = "fullSearch" a.className = "searchLink" div.appendChild(a); } } function setSearchLink() { var a = document.getElementById("fullSearch"); a.href = a.href.split("?search=")[0] + "?search=" + document.getElementById("searchInput").value + "&fulltext=" + a.href.split("&fulltext=")[1] } addLoadEvent(searchLink); /* </nowiki></pre> */