Jump to content

User:Sisyph/ContribColors.js

From Wikipedia, the free encyclopedia
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.
/**
 * Présentation : [[Discussion Projet:JavaScript#Contribution Deluxe]]
 * Auteur : Chphe
 * [[Catégorie:MediaWiki:Fonction Monobook en JavaScript]]
 */
 
function contribColors()
{
  var list = document.getElementById('bodyContent').getElementsByTagName('li');
  for(var i=0; i<list.length; i++)
  {
    var ind = list[i].childNodes.length-2;
    if(ind<=0) continue;
    var elem = list[i].childNodes[ind];
    if(elem.nodeName=='SPAN' && elem.className != "mw-uctop")
    { 
       ind -= 2;
       if(ind<=0) continue;
       elem = list[i].childNodes[ind];
    }
    if(elem.nodeName=='SPAN' && elem.className == "mw-uctop") list[i].className = 'contrib-last';
    else list[i].className = 'contrib-normal';
  }
}
 
if(wgPageName == "Spécial:Contributions") addOnloadHook(contribColors);