Jump to content

User:Leag/OngletGoogle.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <nowiki>
/* {{Projet:JavaScript/Script|OngletGoogle}} */
 
/*
 * Onglet Google
 *
 * Rajoute un onglet vers Google portant sur le titre de la page
 *
 * Auteur : Dake, Hégésippe, Phe
 * Mise à jour mediawiki 1.19 : Lgd
 * Dernière révision : 6 mars 2012
 */
 
var OngletGoogle = function ($) {
 
  function GoogleQuoteSearch() {
    var result = mw.config.get( 'wgPageName' ).replace( /_/g, "+" );
    if ( mw.config.get( 'wgPageName' ).search( /\(/ ) == -1 ) {
      result = "" + result + "";
    }
    return result;
  }
 
  if (mw.config.get('wgNamespaceNumber') >= 0) {
    var googleWeb = 'http://www.google.fr/search?num=20&safe=off&q=' + GoogleQuoteSearch() + '&btnG=Search';
    var googleImage = 'http://www.google.fr/search?num=20&safe=off&q=' + GoogleQuoteSearch() + '&um=1&ie=UTF-8&hl=fr&tbm=isch&source=og&sa=N&tab=wi';
    mw.util.addPortletLink( 'p-cactions', googleWeb, 'Google');
    mw.util.addPortletLink( 'p-cactions', googleImage, 'Images');
  }
}
$(document).ready(OngletGoogle);
// </nowiki>