SJ cartoon avatar

Productivity Don't Just Block Sites… Re-Direct Them!

Has this ever happened to you?

Note: Completely rhetorical question - as I already know that the answer is a resounding “Yes!”

A Completely Hypothetical Story

You sit down at your computer brimming with optimism about all the work you’re about to crush to get ready for the big demo - but first, you just need to quickly reply to that guy on Twitter about why Angular is better than React…

Fast-forward to 10 hours (and 4000 tweets) later and you’re getting ready to pack up for the day, happy about how you handled that troll, but a bit miffed that you didn’t get any work done.

“Oh well, there’s always tomorrow” you say…

Fast-forward to 3 weeks later, and you’re hiding under a table at CES so you don’t have to explain why your live demo seems very much like a hacked-together screen recording playing in a loop.

You get home a few days later promising this would never happen again, and DEFINITELY won’t happen for your next demo in a month. So you crack open your laptop, ready to hit the ground running… But first, what’s with this jerk tweeting that Aurelia is better than VueJS???

XKCD comic about feeding trolls XKCD

So true it hurts a little

I’ve love to say that the above story has never happened to me, since I don’t spend much time on Twitter, and I know better than to get into a flame-war about a JS library - but it still rings painfully true to me.

More often than I’d like to admit, I find myself with a pressing deadline that seems to have come out of the blue. About 80% of the time, it’s because the client springs a last minute, urgent project on me - which leads to all sorts of hacking and slashing that I’m not proud of, but had little say in.

The other 20% of the time however… Well, that’s on me.

I have more than enough time to meet a deadline (read: I am given approximately the amount of time a project/feature will take), but I still find myself working at the 11th hour. There’s not necessarily any one reason for this - but the lost hours on my computer doing stupid stuff ranks pretty high.

So… Time to solve that!

Pop and Blockathon

via GIPHY

Knowing that I waste all kinds of time on certain websites… Well, why not just stop them from being accessible to my computer at all?

How do we do this? Pretty simple actually - edit the hosts file and block each URL.

In your /etc/hosts file, add this:

127.0.0.1 facebook.com
127.0.0.1 twitter.com
127.0.0.1 tsn.ca
127.0.0.1 linkedin.com
127.0.0.1 netflix.com

And (on Mac), then call this:

sudo dscacheutil -flushcache

Basically, what this is doing is that any time you enter one of those websites into (any) browser, they’ll automatically be re-directed to your localhost.

Works kind of like this:

via GIPHY

Mind Freak

via GIPHY

The hosts method worked pretty damn well for me. It was such a natural habit for me to go to a couple of websites when I’m bored, distracted, or looking for a distraction.

I’d type in some random time wasting website, then get stonewalled by this:

Chrome error page when blocking sites using /etc/hosts file]

The underlying problem is that my brain is looking for a distraction, so when I open a browser and type in “tsn.ca” - there was no real conscious effort. It was just a habit… I wouldn’t even consciously think about it, until I had spent a few minutes browsing some stories (ditto for reddit, linkedin, etc) - and then I would be like “goddammit, how did I get here? When the hell did I open this tab?”. Brain was entirely on autopilot.

So, functionally, this hosts blocker was really good. I couldn’t go to some of my time killer websites, and I wouldn’t lose a couple minutes (or hours) per instance… BUT! This definitely did put a mental block and a context switch into play, which takes me a couple of minutes to recover from each time.

This got me thinking… If it’s just a habit to go to some of my problem websites - maybe I could make it a habit to go to a productive website.

Block Ness Monster

To test this theory out I decided to write my first ever Chrome plugin. I’d had this in the back of my mind for months, but I assumed there was a lot of start-up, and reading, and learning I needed to do…

As it turned out, it took exactly 42 minutes to figure out how to write my plugin, write it, enable it in Chrome - and it’s been there ever since.

https://github.com/sureshjoshi/block-ness-monster

It’s only a handful of lines of code, and the popup portion isn’t even used right now (maybe one day I’ll update it to add start/end times, and maybe even changing redirects and such).

I’ve hardcoded some sites I want to avoid (I don’t know why I included Facebook - I haven’t had an FB account in years) and when Chrome tries to go to those sites, my browser is automatically re-directed to my pending BitBucket issues list (or Github issues, or whatever). Super clean, super simple.

What’s supremely crazy is that, it’s so habitual (and not conscious behaviour) when I type in tsn.ca, that now when it auto-redirects me, I start going through my tickets thinking that was the site I was supposed to be on all along

The other day, I typed “tsn.ca” in, it auto-redirected to BitBucket (I don’t even see the TSN website - the URL redirects automatically without loading the page), then I completed a couple tickets in 10 minutes, and afterwards I was like.. “Wait, What the hell… I was supposed to be looking at sports!”

What about the other extensions?

I’m aware that there are other URL blockers and such in the Chrome Web Store, but I keep my extensions list pretty tight. I’d prefer random companies not have access to my browsing history and whatever else they can glean from the Chrome permissions they take.

Remember - if a business is giving you something for free, then you’re the product.