Reddit Comment Highlighter

By Erik Wannebo Last update Jun 16, 2009 — Installed 108 times. Daily Installs: 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

There are 5 previous versions of this script.

// ==UserScript==
// @name           Reddit Comment Highlighter
// @namespace      gmonkeyfilter
// @description    Highlights comments for reddit stories based on comment points
// @include        http://www.reddit.com/*/comments/*
// @require	  http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
// ==/UserScript==

var ChangeFontSize=true;
var maxFontSize=24;


var $=window.jQuery;
window.jQuery.noConflict();
var thresholds={
.75:'#FFFFcc',
.9:'#FFFF99',
.95:'#FFFF66',
.98:'#FFFF33'
}
var maxrecs=0;
$(document).ready(function(){
	var arRecs=new Array();
	$(".entry .score").each(function(){
		var recs=$(this).text().split(' ')[0];
		arRecs.push(parseInt(recs));
		if(parseInt(recs)>maxrecs)maxrecs=parseInt(recs);
	});
	arRecs.sort(function (a, b) {return a - b;});
	$(".entry .score").each(function(){
		var recs=$(this).text().split(' ')[0];
		var numrecs=parseInt(recs);
		var newbgcolor='';
		var newfontsize=12;
		for(t in thresholds)
			if(numrecs>=arRecs[Math.floor(arRecs.length*t)]){
				newbgcolor=thresholds[t];
			}else{
				break;
			}
		if(newbgcolor!=''){
		$(this).parents("div.entry").css({backgroundColor: newbgcolor});
		if(maxrecs>0)newfontsize+=(maxFontSize-12)*Math.pow(numrecs/maxrecs,0.6);//???
		if(ChangeFontSize)$(this).parents("div.entry").find(".md").css({fontSize: newfontsize});
}
	});
});