MediaWiki:Gadget-ArchiveLinks.js
Apparence
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) ;
Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5./**
* Application de [[Wikipédia:Prise de décision/Système de cache]].
* Un <span class="noarchive"> autour d'un lien l'empêche d'être pris en compte.
*
* {{Catégorisation JS|ArchiveLinks}}
*/
if (mw.config.get('wgNamespaceNumber') === 0 || mw.user.options.get('gadget-ExtendedCache')) {
$(function ($) {
archiveLinks();
});
}
function archiveLinks() {
var selector = mw.user.options.get('gadget-ExtendedCache') ? 'a.external' : 'ol.references a.external';
$(selector).each(function () {
var $this = $(this);
var chemin = this.href;
if (/(^|\.)wiki([pm]edia|data)\.org$/.test(this.hostname)
|| chemin.indexOf('http://archive.wikiwix.com/cache/') === 0
|| chemin.indexOf('http://wikiwix.com/cache/') === 0
|| chemin.indexOf('http://web.archive.org/web/') === 0) {
return;
}
if ($this.parents().hasClass('noarchive')) {
return;
}
// sécurité : attention à échapper les quotes dans les attributs
var href = 'http://archive.wikiwix.com/cache/?url=' + encodeURIComponent(chemin);
var title = 'archive sur Wikiwix';
var link = '<a href="' + href + '" title="' + title + '">archive</a>';
$this.after('<small class="cachelinks">\u00a0[' + link + ']</small>');
});
}