Utilisateur:Passawuth/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> */
 
// ========== Modifier EditSection0 ==========
/*
 * AddEditSection0
 *
 * Permet d'éditer la première section d'une page (en-tête)
 * Contributeur : Pabix, Zelda
 * Dernière révision : 12 novembre 2006
 */
 
function addEditSection0() {
        ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
        if (!document.getElementById) {
                return;
        }
        x = document.getElementById('ca-edit');
        if(!x) {
                return;
        }
        y = document.createElement('LI');
        y.id = 'ca-edit-0';
        if (x.className == 'selected') {
                if (/&action=edit&section=0$/.test(window.location.href)) {
                        x.className = 'istalk';
                        y.className = 'selected';
                } else {
                        x.className = 'selected istalk';
                }
        } else if (x.className == 'selected istalk') {
                if (/&action=edit&section=0$/.test(window.location.href)) {
                        x.className = 'istalk';
                        y.className = 'selected istalk';
                } else {
                        y.className = 'istalk';
                }
        } else {
                y.className = x.className;
                x.className = 'istalk';
        }
        z = document.createElement('A');
        if (x.children) {
                z.href = x.children[0].href + '&section=0';
                z.appendChild(document.createTextNode('0'));
                y.appendChild(z);
                x.parentNode.insertBefore(y,x.nextSibling);
        } else {
                z.href = x.childNodes[0].href + '&section=0';
                z.appendChild(document.createTextNode('0'));
                y.appendChild(z);
                x.parentNode.insertBefore(y,x.nextSibling);
        }
}
if (document.title.indexOf("Modification ") == -1) {
        addOnloadHook(addEditSection0);
}
 
// ========== Cleaning up article ==========
//<!-- nocleanup -->
// adapted and edited from [[:th:WP:US]] & [[:th:User:Jutiphan/Scripts/mainTabs/monobook.js]] -- use for speedy cleanup 
 
function doCleanupTag(){text=document.editform.wpTextbox1.value;if(text.indexOf("nocleanup")>=0){alert("This page does not expected you to cleanup because it may cause some problems");return}
 
  text = text.replace(/<br>|<br\/>/gi, "<br />");                                   //<br/> -> <br />
  text = text.replace(/([^\[]|^)\[([^\[^\]]*?)\]\]/gm, "$1[[$2]]");                   //[Link]] -> [[Link]]
  text = text.replace(/\[\[([^\[^\]].*?)[$[^\]]?]/gm, "[[$1]]");                      //[[Link] -> [[Link]]
  text = text.replace(/\[\[ ?([^\]\|]*?) \s*([\|\s|\]\]])/g, "[[$1$2");               //[ Link ]] -> [[Link]]
  text = text.replace(/^([\*#]+) /gm, "$1");
  text = text.replace(/^([\*#]+)/gm, "$1 ");
  text = text.replace(/^= ?([^=].*?) ?=/gm,"== $1 ==");                               //= Topic =  -> == Topic ==
  text = text.replace(/^(={1,5}) *(.*?) ?(={1,5}) *$/gm, "$1 $2 $3");                   //==Topic== -> == Topic ==
  text = text.replace(/&prime;/g, "'");
  text = text.replace(/&amp;/g, "&");
  text = text.replace(/&minus;/g, "−");
  text = text.replace(/&times;/g, "×");
  text = text.replace(/&mdash;/g, " —");
  text = text.replace(/&ndash;/g, " -");
 
  //[[Categorie: xxx]] -> [[Categorie:xxx]]
  text = text.replace(/\[\[Categorie:\s(.*?)\]\]/g,"[[Categorie:$1]]");
 
  //[[Category:xxx]] -> [[Categorie:xxx]]
  //[[Template:xxx]] -> [[Modèle:xxx]]
  text = text.replace(/\[\[Category:/gi,'[[Categorie:');
  text = text.replace(/\[\[Template:/gi,'Modèle:');
 
  //{{Modèle:xxx}} -> {{xxx}}
  text = text.replace(/{{Modèle:(.*?)}}/g,"{{$1}}");
 
  //Fix spacing, </xxx > -> </xxx>
  text = text.replace(/<\/(.*?) ?>/g,"</$1>");
 
  text = text.replace(/(.[^\s\[\(]\_)\(/g,"$1 (");
  text = text.replace(/\)([^\s\]\)\|\.\_])/g,") $1");
  text = text.replace(/\* ?({{.*?icon}}) ?(.*?)\r?\n/g,"* $2 $1\n");                           
  text = text.replace(/<ref(.*?)> ?({{.*?icon}}) ?(.*?) ?<\/ref>/g,"<ref$1>$3 $2</ref>");
  text = text.replace(/ *\|(?!-) *\r?\n *([^=\*<|{}]*?) ?=(?!=) *([^\|={}]*?)/gm,"\n| $1 = $2");      
  text = text.replace(/\n *\|(?!-) *([^={}\*].*?) ?= *([^<={}]*?) \| ?( *}} *\r?\n| *\r?\n *}} *\r?\n)/g, "\n| $1 = $2\n}}\n");
  text = text.replace(/\n *\|(?!-) *([^=\|'"{}]*?) ?= *([^=]*?) *\r/g,"\n| $1 = $2");
  text = text.replace(/\n(={1,5}) ?''' ?(.*) ?''' ?(={1,5})/gm, "\n$1 $2 $3");
  text = text.replace(/\n *\|(?!-) *([^=\|'"{}]*?)=([^=\|]*?) ?\| ?\r?\n?\}\}/g, "\n| $1 = $2\n}}");
 
  if(wgNamespaceNumber == 0 && wgPageName.indexOf("Wikipédia:") != 0) {
    //Remove signatures on article pages
    text = text.replace(/-{0,2} ?\[\[Utilisateur:.*/g,"");
 
    //Remove begin line spaces to help newcomers
    text = text.replace(/== ?\n *(.*\n)/gi, "==\n$1");
  }
 
 
document.editform.wpTextbox1.value=text;document.editform.wpMinoredit.checked=true;document.editform.wpSummary.value="Edit + Cleaning up"}function addCleanupTag(){addTab("javascript:doCleanupTag() ","♦ Clean","ca-taclt","Cleanup ","")}if(document.title.indexOf("Editing ")==0){if(window.addEventListener)window.addEventListener("load",addCleanupTag,false);else if(window.attachEvent)window.attachEvent("onload",addCleanupTag)}
 
 
obtenir("ResumeDeluxe");
obtenir("HotCats");
 
 
/* </nowiki></pre> */