JavaScript fun

For an interesting distraction, I've been playing around with creating a Chrome extension to try and measure how long it takes to read a given web page.

The simple prototype version was up and running relatively quickly. And then the real fun began.

Turns out there's a whole bunch of ways you can open up a web page and get to the bottom. It could be there to begin with. You could scroll. You could click to go directly to the bottom. And probably a few others I haven't yet thought of.

On top of that, nobody ever said you have to stay on the page after opening it. You can get distracted by something else and open that, and then come back. You might get up and go and make a cup of tea and come back minutes if not hours later.

So, my nice simple code has gradually become more and monstrous, but in a good way.

My final challenge is to figure out a way of intercepting how Medium manages to change articles without actually triggering any of my new page detection. There's something clever going on, and I'm not (yet) smart enough to figure it out!

Thankfully I only have to deal with Chrome, and jQuery abstracts away a lot of the really complicated stuff. I can't imagine trying to get this to work cross-browser without jQuery...!

[Image credit: Jayel Aheram]