from Hacker News

Show HN: I made a bookmarklet to make HN headlines easier to scan

by notmysql_ on 5/15/24, 3:21 PM with 0 comments

Last night I hacked together a little JS snippet that changes the font size of headlines to their associated score on a log scale. You can see an example screenshot here => https://i.imgur.com/Cr0weKW.png

  const SCALE = 2;

  const bl_children = document.getElementsByTagName("tbody")[2].children;

  for(let i = 1; i < bl_children.length-1; i += 3){
    const title = bl_children[i-1].children[2].children[0].children[0];
    const score_body = bl_children[i];
    const score = parseInt(score_body.children[1].children[0].children[0].innerText.split(" ")[0],10);

    const size = Math.log2(score+13.33/SCALE) * SCALE;
    title.style.fontSize = size + "px";
  }