Jump to content

User:Markhurd/watchcontrib.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Markhurd (talk | contribs) at 16:31, 8 June 2009 (Watch contrib -- same as hide contrib, except it also hides all subsequent contributions to the same page). 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.
// Based on [[/hidetopcontrib.js]]

// This script hides lines according to who has the top contribution for a page.
// Also hides subsequent contribution to the same page in all cases.

//<pre><nowiki>

function watchcontrib()
{
   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\/([^"]*)"/); // " fix simple WP syntax highlighter

     if(t!=undefined)
       t=t[1];
     else
     {
       t=li[i].innerHTML.match(/"\/w\/index\.php\?title\=([^&]*)\&amp\;redirect\=no"/);

       if(t!=undefined)
         t=t[1];
       else
         continue;
     }

     if(li[i].getElementsByTagName("strong").length>0)
       s="none";
     else
       s="";

     if(a[t]!=undefined)
       s="none";
     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:watchcontrib()', 'watch top', 'ca-watchtop',
                    "Show/hide pages for which you're the top contributor", '');
 });

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