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:Ais523/topcontrib.js]]
// This script color-codes lines according to who has the top contribution for a page.
addOnloadHook(function () {
     // the ais523 in the line above is meant to be ais523, not your username; it's
     // to avoid a clash with a couple of other scripts I've written. Feel free to
     // expand it to avoid clashes with other contribs-manipulating scripts, though.
    var i,li,a;
    a=new Array();
      var s,t;
      var html = li[i].innerHTML;
      var match = html.match(/"\/wiki\/([^"]*)"/);
      if (!match)
        match = html.match(/"\/w\/index.php\?title=([^"]*)&amp;redirect=no"/);
      t = match[1];
      var spans = li[i].getElementsByTagName("span");
      var topspanfound = false;
      for (var j = 0; j < spans.length; j++)
        if (spans[j].className == "mw-uctop")
           topspanfound = true;
      s = topspanfound ? "#CCCCFF" : "#FFCCCC";
      if(a[t]!=undefined) s=(a[t]=="#CCCCFF"?"#CCFFFF":"#FFFFCC"); else a[t]=s;
      li[i].innerHTML="<SPAN STYLE='background-color:"+s+"'>"+li[i].innerHTML+"</SPAN>";
//[[Category:Wikipedia scripts]]
Personal tools