Utilisateur:Dodoïste/archive.js
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.addOnloadHook(function () {
if (mw.config.get('wgNamespaceNumber') == 0) {
if ((typeof no_external_cache != "undefined") && (no_external_cache)) return;
addcache();
}
function addcache() {
var external_links = document.querySelectorAll('a.external');
for( i = 0;i < external_links.length;i++)
{
var chemin = external_links[i].href;
if(chemin.indexOf("http://wikiwix.com/cache/")==-1 && chemin.indexOf("http://web.archive.org/web/*/")==-1)
{
var li = external_links[i].parentNode;
var depth = 0;
while ((depth < 3) && (li.tagName != "LI") && (li.parentNode != null)) {
li = li.parentNode;
depth++;
}
if (li.tagName != "LI") continue;
var last = li.lastChild;
if ((last.tagName == "SUP") && (last.getAttribute("class") == "cachelinks"))
{
last.replaceChild(document.createTextNode(", "), last.lastChild);
}
else
{
last = document.createElement("small");
last.setAttribute("class", "cachelinks");
last.appendChild(document.createTextNode("\u00a0["));
li.appendChild(last);
}
var link = document.createElement("a");
link.setAttribute("href", "http://web.archive.org/web/*/" + chemin.replace(/&/g, "%26"));
link.appendChild(document.createTextNode("archive"));
link.style.color = "#AAAAFF";
last.appendChild(link);
last.appendChild(document.createTextNode("]"));
}
}
}
}
);