Usuário:Heldergeovane/Scripts/Última contribuição.js

Origem: Wikilivros, livros abertos por um mundo aberto.

Nota: Após gravar, terá de limpar a cache do seu navegador para ver as alterações. Mozilla / Firefox / Safari: pressione Shift enquanto clica em Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (Command-R num Macintosh); Konqueror:: clique no botão Recarregar ou pressione F5; Opera: limpe a cache em Ferramentas → Preferências (Tools → Preferences); Internet Explorer: pressione Ctrl enquanto clica em Recarregar ou pressione Ctrl-F5.

// [[User:Ais523/topcontrib.js]]
 
// This script color-codes lines according to who has the top contribution for a page.
//<pre><nowiki>
 
    addOnloadHook(function () {
		var i,li,a;
		li=document.getElementById("bodyContent");
		li=li.getElementsByTagName("li");
		i=-1;
		a=new Array();
		while(++i<li.length)
		{
			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];
			if(li[i].getElementsByTagName("strong").length>0)
				s="#CCCCFF";
			else
				s="#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>";
		}
    });
//</nowiki></pre>
//[[Category:Wikipedia scripts]]