Run a setInterval that temporarily pauses when the page is not visible.
npm install set-interval-visible
Demo →
View source →
MIT license.