YC News Bookmarklet using Yahoo Pipes
on May 21, 2008Yesterday I had a long phone call with my friend Peter Tegelaar about the usual stuff that interests us: the web, startups, the semantic web, natural language parsing, mobile web, recommendation engines etc. At a certain point we came to discuss his YCombinator News karma and it got me thinking about what a nice way it is to highlight quality content in a system.
The news submission to YCombinator News (Hacker News) is very important too one's karma. The trick is to submit news that is new, original and intellectually aligned with the YC community. So I thought it would be nice to have a bookmarklet to submit entries to HN, and naturally that bookmarklet already exists.
However, the current bookmarklet is lacking a feature I thought would be very useful:- If the URL is already submitted, don't submit but go to the comments page of that URL.
- If the URL is new, go to the submission page.
here is the final resulting bookmarklet, to install drag this to your bookmark bar (IE7 and Firefox tested)
to YC News
- A JSON feed of the top entries.
- A JSON feed of the recently submitted entries.
Some of you might know that I've made the little project Wigitize.com. Basically wigitize is a simple RSS to JSON converter. However, with Yahoo Pipes you can do a lot more. Using Yahoo Pipes I've made two data feeds that can be represented in numerous formats including JSON:
- HN Newest, a pipe that scrapes the newest page using a maze of regular expression renames.
- HN Top and Newest, a combined feed of the top and newest entries (uses the first pipe).
While using Yahoo Pipes I had to do a lot of hacking and screwing around to scrape the page, something I could've done far more quickly using conventional scripting. Heard of any such service?
The resulting bookmarklet is build upon the original by Phil Kast. It uses the Top and Newest Yahoo Pipe to determine whether an article has been submitted already (of course the pipe will lag behind a bit in time, so it will not work perfectly).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
function to_hacker_news(pipe) { var items = pipe.value.items; var url = 'http://news.ycombinator.com/submitlink?u='+encodeURIComponent(document.location)+'&t='+encodeURIComponent(document.title); for(var i=0; items.length > i; i++) { if(items[i]['link'] == document.location) { url = items[i]['comments']; } } window.location = url; }; function bookmark_to_hacker_news() { var script = document.createElement('script'); script.src='http://pipes.yahoo.com/pipes/pipe.run?_id=emucF0ci3RGfI6mHxAnzeQ&_render=json&_callback=to_hacker_news'; document.getElementsByTagName('head')[0].appendChild(script); }; bookmark_to_hacker_news(); |
I don't use YC News as often as I should, but I've decided to roll it into my habits. Because of that I might as well have solved a problem that was in no way worth solving (conceptual mistake), but I did have a chance to practice making my first Pipe and Bookmarklet.
Peter noted that it would be nice to upgrade this bookmarklet to support bookmarking directly from Google Reader. Any takers? That would be a nice hack indeed!