node check if chrome active code example
Example: if browsertab is active jquery
document.addEventListener('visibilitychange', function() {
if(document.hidden)
console.log('Page is hidden from user view');
else
console.log('Page is in user view');
});