Jump to content

User:Ais523/hidetopcontrib.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ais523 (talk | contribs) at 07:31, 25 September 2007 (a modified copy of User:ais523/topcontrib.js, per request by User:Discospinster). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// [[User:Ais523/hidetopcontrib.js]]
// By a suggestion by [[User:Discospinster]]

// This script color-codes lines according to who has the top contribution for a page.
//<pre><nowiki>

function hidetopcontrib()
{
  var i,li,a;
  li=document.getElementById("bodyContent");
  li=li.getElementsByTagName("li");
  i=-1;
  a=new Array();
  while(++i<li.length)
  {
    var s,t;
    t=li[i].innerHTML.match(/"\/wiki\/([^"]*)"/)[1];
    if(li[i].getElementsByTagName("strong").length>0)
      s="none";
    else
      s="";
    if(a[t]!=undefined) s=a[t]; else a[t]=s;
    if(s!="") li[i].innerHTML="<SPAN STYLE='display:"+s+"'>"+li[i].innerHTML+"</SPAN>";
  }
}

addOnloadHook(function () {
  if((location.href.indexOf("Special:Contributions")!=-1||
      location.href.indexOf("Special%3AContributions")!=-1)
     &&location.href.indexOf("&ais523")==-1&&location.href.indexOf("?ais523")==-1)
    addPortletLink('p-cactions', 'javascript:hidetopcontrib()', 'hide top', 'ca-hidetop',
                   "Hide pages for which you're the top contributor", '');
});
//</nowiki></pre>
//[[Category:Wikipedia scripts]]