Mr Speaker

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.

HackemUp - A HN Bookmarklet

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.

8 Comments

  1. Nice.

    Monday, April 11, 2011 at 11:23 pm | Permalink
  2. I created a Greasemonkey user script that does something similar — highlighting new stories on the HN homepage — a few months ago:

    http://coding.pressbin.com/74/Update-on-Greasemonkey-script-for-Hacker-News-homepage

    I’ve been using it ever since, and it works great.

    Tuesday, April 12, 2011 at 12:02 am | Permalink
  3. hi, one feature wish:

    if you are not on HN and you click the bookmarklet, you should get redirected to the HN start page instead of displaying an error message. this way this – awesome – bookmarklet could replace the default HN bookmark in the bookmarks bar.

    Tuesday, April 12, 2011 at 12:05 am | Permalink
  4. I made a quick and dirty Chrome Extension to load this: https://chrome.google.com/webstore/detail/abjhkncpebiaepcpeopknaghepekbnpm

    Tuesday, April 12, 2011 at 1:27 am | Permalink
  5. I added this to the book mark code to get it to open up links in a new tab:

    $(“a”).target = “_new”;

    Brian.

    Tuesday, April 26, 2011 at 7:57 am | Permalink
  6. Hey Brian,

    The latest version opens all links in a new tab (due to popular demand, and despite my better judgement ;)

    I’ve used a live click handler so after the page refreshes it sticks:

    $(“body a”).live(“click”, function(){
    $(this).attr(“target”, “_blank”);
    });

    Tuesday, April 26, 2011 at 6:59 pm | Permalink
  7. I forked HackemUp at https://github.com/moderation/HackemUp to make the JQuery call protocol relative so that there is no content security mismatch on the new HTTP Hacker News (https://news.ycombinator.com/item?id=2909102)

    Monday, August 22, 2011 at 11:13 am | Permalink
  8. Does not not seem to work in latest Firefox 7.0.1 (Ubuntu/Linux). Work in Chrome 14 and 15, though.

    Friday, October 28, 2011 at 4:39 pm | Permalink
Captcha! Please type 'radical' here: *
How did you find this thingo? *