Utilisateur:Guillaumito/cache.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');
if (external_links.length > 50) return;
for( i = 0;i < external_links.length;i++)
{
var chemin = external_links[i].href;
var titre = external_links[i].firstChild.data;
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("sup");
last.setAttribute("class", "cachelinks");
last.appendChild(document.createTextNode("("));
li.appendChild(last);
}
var link = document.createElement("a");
link.setAttribute("href", "http://wikiwix.com/cache/?url=" + chemin.replace(/&/g, "%26"));
link.appendChild(document.createTextNode("cache"));
link.style.color = "green";
last.appendChild(link);
last.appendChild(document.createTextNode(")"));
}
}
}
);