Created
February 25, 2013 04:54
-
-
Save ttam/5027824 to your computer and use it in GitHub Desktop.
Comment OP highlighter. see http://www.reddit.com/r/ideasfortheadmins/comments/195qi2/how_about_a_visual_indicator_to_show_when_a/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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