One thing I'd add to this is to schedule it in the future. Sometimes, you can't bring yourself to block all websites right now, but you can happily make it a problem for your future self. I've written a similar script to do this and had success with it.
Something like:
checking 60m --start-in 30m