Utilisateur:Serpicozaure/monobook.js

Une page de Wikipédia, l'encyclopédie libre.
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
/**
 * Display a counter of how many times the page has been consulted.
 * The counter is displayes in the upper right corner of the page.
 * It requires Firefox 2.0 (uses client side persistent storage),
 * and will NOT work under other non-gecko browsers (IE, OPERA, ...)
 * author : Zelda for fr.wikipedia.org
 */

// counter label (internationnalizable and personnalizable variable)
var pgCounterLabel = "<small>page consultée <b>$count</b> fois  [<a href=\"javascript:resetPageCounter()\">RAZ</a>]</small>";

// prefix for counter storage (shorter is better)
var pgCounterPrefix = "counter."

/**
 * Increments and displays page counter
 */
function pageCounter() {
  if (! globalStorage) {
    alert("This page counter uses persistent storage features and requires Mozilla Firefox 2.0");
    return;
  }
  // Counter only available in main namespace to spare storage
  if (mw.config.get('wgNamespaceNumber') != 0)
    return;
  if (mw.config.get('wgAction') != "view")
    return;
  // Retrieve and increment counter
  var count = getPageCounter() + 1;
  setPageCounter(count);
  displayPageCounter(count);
}

/**
 * Return page counter global storage
 */
function getPageCounterStorage() {
  return globalStorage[location.hostname];
}

/**
 * Return page counter as an integer
 */
function getPageCounter() {
  var count = getPageCounterStorage().getItem(pgCounterPrefix + mw.config.get('wgArticleId'));
  if (! count) return 0;
  return parseInt(count);
}

/**
 * Page counter setter
 */
function setPageCounter(count) {
  getPageCounterStorage().setItem(pgCounterPrefix + mw.config.get('wgArticleId'), count);
}

/**
 * Reset counter for ALL pages
 */
function resetPageCounter() {
  var storage = getPageCounterStorage();
  for (var i = 0; i < storage.length; i++) {
    var key = storage.key(i);
    if (key.substr(0, pgCounterPrefix.length) == pgCounterPrefix) {
      storage.removeItem(key);
    }
  }
  // updating counter
  var counter = document.getElementById("page-counter");
  if (counter) {
    counter.innerHTML = pgCounterLabel.replace(/\$count/, getPageCounter());
  }
}

/**
 * Display page counter
 */
function displayPageCounter(count) {
  var counterDiv = document.createElement("div");
  counterDiv.innerHTML = pgCounterLabel.replace(/\$count/, count);
  counterDiv.style.textAlign="right";
  counterDiv.id = "page-counter";
  var contentNode = document.getElementById("content");
  contentNode.insertBefore(counterDiv, contentNode.firstChild);
}

$(pageCounter);

//This code will change ISBN links to point to the url of your choice,
//instead of Special:Book_sources. 
//
//How to use it:
//
//First, you must copy this code to your user javascript page. This is 
//at User:<your username>/monobook.js . My username is Lunchboxhero so
//my javascript page is User:Lunchboxhero/monobook.js . You must be logged
//in to edit your javascript page.
//
//Once you have copied the code and saved the page, you need to refresh your
//browser's cache. For Mozilla/Safari/Konqueror: hold down Shift while clicking 
//Reload (or press Ctrl-Shift-R), IE: press Ctrl-F5, Opera: press F5.
//
//The code should now work, as long as you are logged in.
//
//You can change the destination URL.  Go to [[Wikipedia:Book sources]] and copy 
//the URL of the site you want to use (right-click the link, then click "Copy Link 
//Location", "Copy Target", or similar).  Put the new URL between the quotes next 
//to magicURL, in place of the URL now there.
//
//The current magicURL includes Wikipedia's Amazon Referral reference. That means if you click on 
//the ISBN link, go to Amazon and end up buying the book, Wikipedia will earn some small amount
//of money from that sale.  If you don't want to support Wikipedia in this way, but do want ISBNs
//to link to Amazon, replace the current magicURL with "http://www.amazon.com/exec/obidos/ASIN/MAGICNUMBER"
//
//Good luck, and if you have any questions, leave a comment on the discussion
//page of User:Lunchboxhero/monobook.js . Thanks to Superm401 and drrngravy for their
//improvements.
//
//(Every line that starts with "//" is a comment and can be discarded.)
 
function externISBN() {
 
var magicURL = "http://www.amazon.com/exec/obidos/ASIN/MAGICNUMBER/wikipedia08-20";
 
  var magicRegex = /MAGICNUMBER/ig;
  if(mw.config.get('wgPageName') != "Special:Booksources" && mw.config.get('wgPageName') != "Wikipedia:Book_sources"){
    for (var i = 0; i < document.links.length; i++) 
    {       
        if( document.links[i].href.match(/isbn=(.*)/) ) {
          document.links[i].href=magicURL.replace(magicRegex, RegExp.$1);
        }
    }
  }
}
 
addOnloadHook(externISBN);




// [[:en:User:Lupin/popups.js]]
// Traduction de [[Utilisateur:Leag|Leag]] : [[Utilisateur:Leag/Navigation popups|Navigation popups]]

importScript('MediaWiki:Gadget-Popups.js');

var ModèleLienweb = '<ref>{{Lien web\n'
+  '|url=\n'
+  '|titre=\n'
+  '|auteur=\n'
+  '|année=\n'
+  '|éditeur=\n'
+  '|consulté le=\n'
+  '}}</ref>';
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/3/3c/Button_lienweb.png','LienWeb',ModèleLienweb,'','','mw-editbutton-lienweb');


var ModèleOuvrage = '<ref>{{Ouvrage\n'
+  '|titre=\n'
+  '|éditeur=\n'
+  '|auteur=\n'
+  '|langue=\n'
+  '|année=\n'
+  '|isbn=\n'
+  '|commentaire=\n'
+  '}}</ref>';
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/4/4b/Books-aj.svg_aj_ashton_01.svg','Ouvrage',ModèleOuvrage,'','','mw-editbutton-Ouvrage');

var ModèleJournal = '<ref>{{Périodique\n'
+  '| lang=\n'
+  '| auteur=\n'
+  '| titre=\n'
+  '| date=\n'
+  '| journal =\n'
+  '| commentaire=\n'
+  '| ISSN =\n'
+  '| texte=\n'
+  '| consulté le=\n'
+  '| }}</ref>';
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/b/b4/Button_lienjournal.png','Journal',ModèleJournal,'','','mw-editbutton-journal');
//<source lang="javascript" line>
/*
* Deluxe Bar
*
* Barre d'outils d'édition étendue
*
* Auteur : Dake
* Modifié par : Sanao
* Dernière révision : 24 novembre 2007
*/ 
function DeluxeBar()
{
  var messages_debut = new Array();
  var messages_fin = new Array();
  var images = new Array();
  var commentaires = new Array();
  var id_images = new Array();
 
  with (messages_debut) 
  {
    push(""); //Bienvenue sur ta page !
    push(""); //Bienvenue !
    push(""); //Blocage d'un vandale
    push(""); //Avertissement vandalisme
    push(""); //Avertissement copyvio
    push(""); //Avertissement spam
    push(""); //Fait
  }
 
  with (messages_fin) 
  {
    push("{{Bienvenu}} ~~~~");
    push("{{Bienvenue nouveau}} ~~~~");
    push("{{Vandale bloqué|1|jour}} ~~~~");
    push("{{Vandalisme|article}} ~~~~");
    push("{{Copieur|article|page copiée}} ~~~~");
    push("{{Bienvenue spammeur|article}} ~~~~");
    push("{{Fait}} ~~~~");
  }
 
  with (images)
  {
    push("https://upload.wikimedia.org/wikipedia/commons/1/12/Button_accueilA.png");
    push("https://upload.wikimedia.org/wikipedia/commons/e/eb/Button_accueilB.png");
    push("https://upload.wikimedia.org/wikipedia/commons/0/00/Button_vandale.png");
    push("https://upload.wikimedia.org/wikipedia/commons/a/a7/Button_smiley3.png");
    push("https://upload.wikimedia.org/wikipedia/commons/5/58/Button_black_copyright.png");
    push("https://upload.wikimedia.org/wikipedia/commons/f/fb/Button_spam2.png");
    push("https://upload.wikimedia.org/wikipedia/commons/d/d9/Button_trait%C3%A9.png");
  }
 
  with (commentaires)
  {
    push("Bienvenue sur ta page !");
    push("Bienvenue !");
    push("Blocage d'un vandale");
    push("Avertissement vandalisme");
    push("Avertissement copyvio");
    push("Avertissement spam");
    push("Fait");
  }
 
  with (id_images)
  {
    push("bienvenue_sur_ta_page");
    push("bienvenue");
    push("blocage_vandale");
    push("avertissement_vandalisme");
    push("avertissement_copyvio");
    push("avertissement_spam");
    push("fait");
  }
 
  //ajoutBoutonsToolbar(messages_debut, messages_fin, commentaires, images, id_images);
  for (var cpt = 0; cpt < images.length; cpt++)
    addButton(images[cpt], commentaires[cpt], messages_debut[cpt], messages_fin[cpt], "", "mw-editbutton-" + id_images[cpt]);


}       
addOnloadHook(DeluxeBar);
//</source>


/******************************************/
/* Amélioration de la boîte de navigation */
/* Auteur : Seb35                         */
/* Bistro d'aujourd'hui par Teofilo       */
/******************************************/
var isOpen = new Array();
var tempo;
function navigationBox_main()
{
 a = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
 m = new Array('janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre'); 
 today = new Date();
 jjmoisaa = today.getDate() + '_' + m[today.getMonth()] + '_' + (today.getYear() + 1900);
 jjmm = today.getDate() + '/' + (today.getMonth()+1);
 
 //Tableau perso à remplir
 var pages = new Array(
  'Général',
      new Array('/wiki/Wikipédia:Le_Bistro/' + jjmoisaa, 'Le Bistro ' + jjmm,
                '/wiki/Wikipédia:Vandalisme_en_cours', 'WP:-(',
                '/wiki/Wikipédia:Requête_aux_administrateurs', 'WP:RA'
               ),
  'Maintenance',
      new Array('/w/index.php?title=Special:Recentchanges&hideliu=1&limit=200', 'RC IP',
                '/wiki/Wikipédia:Pages_à_fusionner', 'WP:PàF',
                '/wiki/Wikipédia:Pages_à_supprimer', 'WP:PàS'
               )
 );
 
 //Liens perso hors menu déroulant
 a.innerHTML = a.innerHTML
  + '<li><a href="/wiki/Special:Newpages" title="Special:Newpages">Nouvelles pages</a></li>';
 
 //----------------------------//
 //Ne pas modifier ce qui suit //
 //----------------------------//
 for(i = 0; i<(pages.length)/2; i++)
 {
  isOpen[i] = 0;
  temp = '';
  for(j=0; j<(pages[2*i+1].length)/2; j++) temp += '<li><a href="' + pages[2*i+1][2*j] + '">' + pages[2*i+1][2*j+1] + '</a></li>';
  a.innerHTML = a.innerHTML
   + '<li>'
    + '<a style="cursor:hand;" onMouseOver="if(!isOpen[' + i + ']) tempo = setTimeout(toggleMenu, 300, ' + (i+1) + ');" '
    + 'onMouseOut="clearTimeout(tempo);" onClick="clearTimeout(tempo); toggleMenu(' + (i+1) + ');" title="' + pages[2*i] + '">'
    + pages[2*i] + '</a>'
   + '</li>'
   + '<div id="MenuToggle' + (i+1) + '" style="display:none;">' + temp + '</div>';
 }
}

/************************************************/
/* Ouvre un menu créé par la fonction ci-dessus */
/************************************************/
function toggleMenu(v)
{
 if(isOpen[v-1] == 0)
 {
  document.getElementById('MenuToggle' + v).style.display = 'block';
  isOpen[v-1] = 1;
 }
 else if(isOpen[v-1] == 1)
 {
  document.getElementById('MenuToggle' + v).style.display = 'none';
  isOpen[v-1] = 0;
 }
}
$(navigationBox_main);

/**
 * raccouci clavier appel patron.
 * The counter is displayes in the upper right corner of the page.
  * author : Zelda for fr.wikipedia.org
 */

// disable Wikipedia access keys/keyboard shortcuts
ta['pt-userpage'] = new Array('+','My user page');
ta['pt-anonuserpage'] = new Array('+','The user page for the ip you\'re editing as');
ta['pt-mytalk'] = new Array('+','My talk page');
ta['pt-anontalk'] = new Array('+','Discussion about edits from this ip address');
ta['pt-preferences'] = new Array('+','My preferences');
ta['pt-watchlist'] = new Array('+','The list of pages you\'re monitoring for changes.');
ta['pt-mycontris'] = new Array('+','List of my contributions');
ta['pt-login'] = new Array('+','You are encouraged to log in; however, it is not mandatory.');
ta['pt-anonlogin'] = new Array('+','You are encouraged to log in; however, it is not mandatory.');
ta['pt-logout'] = new Array('+','Log out');
ta['ca-talk'] = new Array('+','Discussion about the content page');
ta['ca-edit'] = new Array('+','You can edit this page. Please use the preview button before saving.');
ta['ca-addsection'] = new Array('+','Add a comment to this discussion.');
ta['ca-viewsource'] = new Array('+','This page is protected. You can view its source.');
ta['ca-history'] = new Array('+','Past versions of this page.');
ta['ca-protect'] = new Array('+','Protect this page');
ta['ca-delete'] = new Array('+','Delete this page');
ta['ca-undelete'] = new Array('+','Restore the edits done to this page before it was deleted');
ta['ca-move'] = new Array('+','Move this page');
ta['ca-watch'] = new Array('+','Add this page to your watchlist');
ta['ca-unwatch'] = new Array('+','Remove this page from your watchlist');
ta['search'] = new Array('+','Search this wiki');
ta['p-logo'] = new Array('+','Main Page');
ta['n-mainpage'] = new Array('+','Visit the Main Page');
ta["n-Main-page"] = new Array('+','Visit the Main Page');
ta['n-portal'] = new Array('+','About the project, what you can do, where to find things');
ta['n-currentevents'] = new Array('+','Find background information on current events');
ta['n-recentchanges'] = new Array('+','The list of recent changes in the wiki.');
ta['n-randompage'] = new Array('+','Load a random page');
ta['n-help'] = new Array('+','The place to find out.');
ta['n-sitesupport'] = new Array('+','Support us');
ta['n-planet'] = new Array('+','Weblog aggregator of Wikimedia-related posts')
ta['t-whatlinkshere'] = new Array('+','List of all wiki pages that link here');
ta['t-recentchangeslinked'] = new Array('+','Recent changes in pages linked from this page');
ta['feed-rss'] = new Array('+','RSS feed for this page');
ta['feed-atom'] = new Array('+','Atom feed for this page');
ta['t-contributions'] = new Array('+','View the list of contributions of this user');
ta['t-emailuser'] = new Array('+','Send a mail to this user');
ta['t-upload'] = new Array('+','Upload images or media files');
ta['t-specialpages'] = new Array('+','List of all special pages');
ta['ca-nstab-main'] = new Array('+','View the content page');
ta['ca-nstab-user'] = new Array('+','View the user page');
ta['ca-nstab-media'] = new Array('+','View the media page');
ta['ca-nstab-special'] = new Array('+','This is a special page, you can\'t edit the page itself.');
ta['ca-nstab-wp'] = new Array('+','View the project page');
ta['ca-nstab-image'] = new Array('+','View the image page');
ta['ca-nstab-mediawiki'] = new Array('+','View the system message');
ta['ca-nstab-template'] = new Array('+','View the template');
ta['ca-nstab-help'] = new Array('+','View the help page');
ta['ca-nstab-category'] = new Array('+','View the category page');

importScript("User:Serpicozaure/wikt-button.js");