Benutzer:APPER/IP-Patrol/js

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen
// IP-Patrol-Vandalenmarkierung
// siehe Benutzer:APPER/IP-Patrol
function IPPatrol_markVandal(vandal, markID)
{
 document.getElementById(markID).innerHTML = "[markiert]";

 var markJS = document.createElement('script');
 markJS.type = 'text/javascript';
 markJS.src = 'http://tools.wmflabs.org/ipp/vandale.php?ip=' + vandal + '&dnr=1';
 document.getElementsByTagName('head')[0].appendChild(markJS);
}

function IPPatrol_addlink() 
{
 // IP-Patrol-Vandalen-Link
 var aTags = document.getElementById('bodyContent').getElementsByTagName('a');
 var search, result;
 var newnode, spacenode, vandalspan, vandallink;
 for (i = 0; i < aTags.length; i++) 
 {
   search = /Spezial:Beiträge\/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/i;
   result = search.exec(aTags[i].href);
   if (result == null)
   {
     search = /Spezial:Beitr%C3%A4ge\/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/i;
     result = search.exec(aTags[i].href);
   }
   if (result != null)
   {
     newnode = document.createElement("span");
     spacenode = document.createTextNode(" ");
     vandalspan = document.createElement("span");
     vandalspan.id = "IPPatrol_marklink_" + i;
     vandalspan.style.fontWeight = "bold";
     vandallink = document.createElement("a");
     vandallink.href = "javascript:IPPatrol_markVandal('" + result[1] + "', 'IPPatrol_marklink_" + i + "');";
     vandallink.appendChild(document.createTextNode("Vandale!"));
     vandalspan.appendChild(document.createTextNode("["));
     vandalspan.appendChild(vandallink);
     vandalspan.appendChild(document.createTextNode("]"));
     newnode.appendChild(aTags[i].cloneNode(true));
     newnode.appendChild(spacenode);
     newnode.appendChild(vandalspan);
     aTags[i].parentNode.replaceChild(newnode, aTags[i]);
   }
 }
}

addOnloadHook(IPPatrol_addlink);