User:Florentyna/vector.js

function WL { // Konfiguration: if ( typeof pfeil == "undefined") var pfeil = " → "; if ( typeof titlebeibehalten == "undefined") var titlebeibehalten = true; var inhalt = document.getElementById("bodyContent"); var redirects = inhalt ? inhalt.querySelectorAll("a.mw-redirect") : []; titlesAendern(redirects); function titlesAendern(reds) { if ( typeof sajax_init_object === 'undefined' ) { return; }     var ziele = []; for (x in reds) { var link = ( reds[x] && reds[x].getAttribute && reds[x].getAttribute("href") ) || '#'; var start = link.indexOf("/wiki/") + 6; // normale wikilinks //if (start == 5) start = 0; var ende = link.indexOf("#", start); if (link.indexOf("/w/index.php?") > -1) { // links mit php-parameter start = link.indexOf("title=") + 6; ende = link.indexOf("&", start); }        if (ende == - 1) ende = link.length; var ziel = link.substring(start, ende); var schondrin = false; for(i=0; i<ziele.length; i++) { if(ziele[i] == ziel) { schondrin = true; break; }        }         if (!schondrin) ziele.push(ziel); }     var url = mw.config.get('wgServer') + "/" + mw.config.get('wgScriptPath') + "/api.php?action=query&format=xml&titles=" + ziele.join("|") + "&redirects"; if ( typeof wl_xmlhttp != "undefined" ) wl_xmlhttp.abort; // Just to make sure... var wl_xmlhttp = new sajax_init_object; wl_xmlhttp.open('GET', url, true); wl_xmlhttp.onreadystatechange = function { if (! wl_xmlhttp) return ; if (wl_xmlhttp.readyState != 4) return; var xml = wl_xmlhttp.responseXML; if (! xml) return ; var r = xml.getElementsByTagName("r"); for(var i=0;i= r.length) break; }           if (j >= r.length) continue; // wurde nicht in xml gefunden var anhang = r[j].getAttribute("to"); if (! anhang) continue; var neuerTitle = pfeil + anhang; if (titlebeibehalten) neuerTitle = title + pfeil + anhang; node.setAttribute("title", neuerTitle); }     };      wl_xmlhttp.send(null); } } addOnloadHook(WL);