Skip to content

Instantly share code, notes, and snippets.

@jsocol
Forked from potch/README.rst
Created January 11, 2012 00:39
Show Gist options
  • Save jsocol/1592222 to your computer and use it in GitHub Desktop.
Save jsocol/1592222 to your computer and use it in GitHub Desktop.
BugColorZilla!
function textColor(bg) {
var r = parseInt(bg.substr(0,2),16),
g = parseInt(bg.substr(2,2),16),
b = parseInt(bg.substr(4,2),16);
var yiq = (r * 299 + g * 587 + b * 114) / 1000;
return yiq >= 128 ? "black" : "white";
}
function bgColor(el, i) {
return ("000000" + $.trim($("a", el).eq(i).text())).substr(-6);
}
var tds = $('.bz_id_column'),
head = $('.bz_alias_short_desc_container'),
start = 0,
i;
function doChunk() {
for (i=start; i<start+20; i++) {
el = tds[i];
if (!el) break;
var c = bgColor(el, 0);
$(el).css('background-color', "#" + c);
$("a", $(el)).css('color', textColor(c));
}
start = i;
if (i<tds.length)
setTimeout(doChunk, 0);
}
if (tds.length) {
doChunk();
}
if (head.length) {
var c = bgColor(head, 1);
$("body").css('background-color', "#" + c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment