Utilisateur:SamuelTardieu/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.
//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.
//
//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.fr/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);
        }
    }
  }
}

$(externISBN);