use page visibility api instead of window.onblur

this lib supports most major browsers