User:Ais523/selfreftab.js

From OpenWetWare

Jump to: navigation, search

Note - After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh); Konqueror: click Reload or press F5; Opera: clear the cache in Tools → Preferences; Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

// <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]]
Personal tools