User:Xavier Combelle/monobook.js

function raccourcis_make_function(links,link,transport,url) { return function { //console.log(transport.getAllResponseHeaders); if (transport.readyState == 4) { var x = (/\#(REDIRECT|REDIRECTION)\s*\[\[(.*?)\]\]/i) .exec(transport.responseText) if(x.length!=3) return; var newTitle = x[2]; links[link].title = newTitle }  } } function addRaccourcis  { var links = document.getElementsByTagName("a"); for (var link = 0; link!= links.length; link ++) { if (links[link].text) { if(links[link].text.substring(0,3)==="WP:") { var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title="+encodeURIComponent(links[link].text)+"&action=raw"; console.log(url); var xmlhttp = new XMLHttpRequest; xmlhttp.open('GET', url, true); var update_link = raccourcis_make_function(links,link,xmlhttp,url); xmlhttp.onreadystatechange = update_link; xmlhttp.send(null); }       }    } } addOnloadHook(addRaccourcis);