Implements browser visibility API

Fixes #14