Skip to content

Instantly share code, notes, and snippets.

@eikes
Created October 23, 2011 20:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eikes/1307837 to your computer and use it in GitHub Desktop.
Save eikes/1307837 to your computer and use it in GitHub Desktop.
Hacker News Polls Visualisation JavaScript Bookmarklet
javascript:(function(){
var s = document.createElement("script");
s.setAttribute("src", "http://code.jquery.com/jquery.js");
document.body.appendChild(s);
s.addEventListener("load", function() {
var $ = jQuery;
var max = 0;
var table = "table tr:eq(3) table:eq(1) ";
$(table).width("100%");
$(table + "tr td:eq(0)").width("15px");
$(table + ".comhead span").each(function() {
var v = parseInt($(this).text());
if (v > max) max = v;
$(this).data("val", v);
}).each(function() {
$(this)
.css({
"width": (100*$(this).data("val")/max)+"%",
"background-color":"white",
"border": "1px solid black",
"display": "block"
});
});
});
})();
javascript:(function(){var a=document.createElement("script");a.setAttribute("src","http://code.jquery.com/jquery.js");document.body.appendChild(a);a.addEventListener("load",function(){var b=jQuery,a=0;b("table tr:eq(3) table:eq(1) ").width("100%");b("table tr:eq(3) table:eq(1) tr td:eq(0)").width("15px");b("table tr:eq(3) table:eq(1) .comhead span").each(function(){var c=parseInt(b(this).text());c>a&&(a=c);b(this).data("val",c)}).each(function(){b(this).css({width:100*b(this).data("val")/a+"%","background-color":"white",border:"1px solid black",display:"block"})})})})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment