Skip to content

Instantly share code, notes, and snippets.

@ttam
Created February 25, 2013 04:54
Show Gist options
  • Save ttam/5027824 to your computer and use it in GitHub Desktop.
Save ttam/5027824 to your computer and use it in GitHub Desktop.
// Bookmarklet:
javascript:(function(){function get_random_color() { var letters = '0123456789ABCDEF'.split(''); var color = '#'; for (var i = 0; i < 6; i++ ) { color += letters[Math.round(Math.random() * 15)]; } return color; }window.authors={};$('a.author').each(function(){var $t=$(this),n=$t.html(),c;if(!(n in window.authors)){c=get_random_color();window.authors[n]=c;$('a.author:contains('+n+')').css('background',c); }});})();
// Full Script:
// This function from http://stackoverflow.com/questions/1484506/random-color-generator-in-javascript
function get_random_color() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.round(Math.random() * 15)];
}
return color;
};
window.authors={};
$('a.author').each(function(){
var $t=$(this),
n=$t.html(),
c;
if(!(n in window.authors)) {
c = get_random_color();
window.authors[n] = c;
$('a.author:contains('+n+')').css('background',c);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment