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.
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
- Open Hacker News.
- 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.)
- Read HN.
- 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
Nice.
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.
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.
I made a quick and dirty Chrome Extension to load this: https://chrome.google.com/webstore/detail/abjhkncpebiaepcpeopknaghepekbnpm
I added this to the book mark code to get it to open up links in a new tab:
$(“a”).target = “_new”;
Brian.
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”);
});
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)
Does not not seem to work in latest Firefox 7.0.1 (Ubuntu/Linux). Work in Chrome 14 and 15, though.