Skip to content

Instantly share code, notes, and snippets.

Created October 23, 2011 20:18
Show Gist options
  • 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
var s = document.createElement("script");
s.setAttribute("src", "");
s.addEventListener("load", function() {
var $ = jQuery;
var max = 0;
var table = "table tr:eq(3) table:eq(1) ";
$(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() {
"width": (100*$(this).data("val")/max)+"%",
"border": "1px solid black",
"display": "block"
javascript:(function(){var a=document.createElement("script");a.setAttribute("src","");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