Well, twitter died on me and I was interested in some parts of the UI and went spelunking with Chrome dev tools.
Realised they were running service workers and here's the code in all its glory. I've linked to a Gist that also has the .coffee
Coffeescript version.