User:Markhurd/hidetopcontrib.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.

//[[User:Markhurd/hidetopcontrib.js]]
// Based on [[User:Ais523/hidetopcontrib.js]]
// By a suggestion by [[User:Discospinster]]
// 090325 MEH Fixed where it is not hiding all (top)s, starting with redirects
//            and continuing after any regex mismatch.
// 090615 MEH Cater for new <span class="mw-uctop">
//            Add userHideAllSubsequent user setting.
//            Fix issue reported by [[User talk:Markhurd/hidetopcontrib.js#Bug|Lenore]].
 
// This script hides lines according to who has the top contribution for a page.
// If userHideAllSubsequent=true, all subsequent contributions are hidden too, more like watchlists.
 
//<pre><nowiki>
 
if (typeof userHideAllSubsequent=='undefined')
 userHideAllSubsequent=false;
 
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,links;
     links=li[i].getElementsByTagName("a");
 
      if (typeof links=='undefined' || links.length<4)
           continue;
 
     t=links[3].innerHTML;
 
     if(li[i].getElementsByTagName("strong").length>0||li[i].innerHTML.match(/\<span +class\="mw\-uctop"\>/)!=undefined)
       s="none";
     else
       s="";
 
     if(a[t]!=undefined)
       s=userHideAllSubsequent?"none":a[t];
     else
       a[t]=s;
 
     if(s!="")
       // li[i].innerHTML=li[i].innerHTML + ":'" + s + "'";
       li[i].style.display=(li[i].style.display=="none"?"list-item":"none");
   }
 }
 
addOnloadHook(function () {
   if((location.href.indexOf("Special:Contributions")!=-1||
       location.href.indexOf("Special%3AContributions")!=-1))
     addPortletLink('p-cactions', 'javascript:hidetopcontrib()', 'show/hide top', 'ca-hidetop',
                    "Show/hide pages for which you're the top contributor", '');
 });
 
//</nowiki></pre>
//[[Category:Wikipedia scripts]]
Personal tools