NPM module
This module is based on the Page Visibility API. It shows when a webpage is in focus or hidden.
npm install page-visible
console.log(PageVisible.visible); // Boolean
PageVisible.on('hidden', function(){
console.log('Page is not visible anymore!');
});
PageVisible.on('visible', function(){
console.log('User is back on the page!');
});