Replying to this post.

It's hacky++ code, but if you want to have a peek behind the curtain, here's a wee gist.

gist.github.com/…/6d664eeea6a5d98b…