I've been using StayFocusd for this exact purpose for years.
As others have mentioned, there are rather a lot of extensions and apps that will selectively block distracting sites for you.
http://lifehacker.com/5452620/stayfocusd-blocks-and-manages-...
Clearly, I have not added HN to my blocklist :)