HackemUp: A HackerNews bookmarklet

Hacker News is a fantastic source for up-to-the-minute happenings in the nerd world. It's highly dynamic - like a calm river of nerditry, in which items of interest ebb and flow unceasingly over the front page. Unfortunately it is also addictive - and the highly procrastinative or inquisitive (or worse still, both) individual can become snared like a reed, prevented from floating productively down the working day.

So here's a bookmarklet that aims to make things both better and worse. It assumes (naturally) that you leave Hacker News open in a tab, on the front page, all day. Naturally. It automatically updates the page whenever you return to the tab. All of the changes are (fairly subtly) highlighted, so it requires but a quick glance to see if you've missed something important.

Let me explain further, in Hacker News form...

HackemUp: A Hacker News bookmarklet

Keep track of what's changed on Hacker News front page since the last time you looked.

1 Show HN: This is what a rising article looks like.
4 Netcraft confirms that this article is dying fast.
+ New article released. Underneath are the updated stats.

7588 points by mrspeaker 3 hours ago | 814 comments

The bookmarklet highlights and updates new articles, articles that are rising or falling fast (drop more than 3), as well as updating comment counts, points, and of course - your karma. Updates every couple of minutes - but if you move to another tab (and leave HN open) no updates will happen until you get back.

Directions

  1. Open Hacker News.
  2. Run the bookmarklet above on the HN page (in Chrome, just drag the link onto the tab - for others, drag the link to the bookmark bar, then switch to NH, then click the bookmark link.)
  3. Read HN.
  4. Every couple of minutes, the page will magically refresh, with changes displayed.

 

...and, some boring details.

Like a true perfectionist, it sprang from a personal need to take Hacker News procrastination to the next level. Perhaps such a bookmarklet or extension already exists, but it would hardly be in the procrastinator spirit to not do it myself. If you want to have a play, the code is on GitHub.

It's pretty straightforward - consisting of the jQuery bookmarklet code, a timer object for watching window blurs and focusses and triggering refreshes, and the guts of it for pulling apart the DOM.

Originally the timer was tied to the requestAnimationFrame which I thought was a pretty sneaky hack: because that timer only ticks when the current tab is focussed. But it only works in Chrome (and FF nightlies, I think) at the moment, so I fell back to window.onfocus. The timer also includes a 1.5 second delay when you return - so refreshes aren't triggered accidentally as you tab past.

The DOM manipulation stuff is a bit hairy because Hacker News has markup from 1997 (another reason to love it): all tables, no classes or IDs. I have a regular-ol' HN account - so it might fail if you have some wiz-bang account that is laid out differently to mine. Lemme know!

PostScript: a couple of people asked me how to change the refresh time from 2 minutes... I haven't exposed anything to do this, but you can just fork the code, or even easier - open up your JavaScript console and type:

hnutimer.refreshTime = 30000;

The time is in milliseconds (30000 is 30 seconds times 1000 milliseconds!)

PPS: HackemUp on Hacker News.