Utilisateur:Guillom/monobook/correcteur.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> */ /* ****************************************** */ /* 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() { var toolbar = document.getElementById("toolbar"); if (!toolbar) return; if ( window.location.href.indexOf('or1=') >= 0 ) { var urlParam = TJSExtraireParam(); replaceortho(urlParam["or1"],urlParam["or2"]); changeSummary('ortho s:/'+urlParam["or1"]+'/'+urlParam["or2"]+'/'); document.editform.submit(); } } addLoadEvent(autoSaveOrtho); /* </nowiki></pre> */