User:Ais523/selfreftab.js

From OpenWetWare
Jump to: navigation, search
// <pre>

addOnloadHook(function ()
{
  var spans = document.body.getElementsByTagName('span');
  var i;
  var a;
  for(i in spans)
  {
    if(spans[i].className!=null)
    if(spans[i].className.toLowerCase().indexOf("selfreference")!=-1)
    {
      //found a selfref
      spans[i].style.display="none";
      a=spans[i].getElementsByTagName("A");
      if(a.length==0) break; //can't find a dablink
      a=a[a.length-1]; //find last hyperlink in the selfref; this will probably be the dablink itself
      addPortletLink("p-cactions",a.href,"WP","ca-dablink","WP","");
      break; //in case of multiple selfrefs, just do one
    }
  }
});

// </pre>
//[[Category:Wikipedia scripts]]