(sorry for my bad english)
I’m developing a basic chrome extension that make some changes to a site. It is all working fine but I can’t get this to work:
When the user is not on the page (is on another tab or minimize the browser) i need to refresh the page every 5 minutes and show a notification if something changed. My problem is to detect if the user is “not on the page”… I tried to do this but didn’t worked:
window.addEventListener('focus', function() {
isVisible = true;
});
window.addEventListener('blur', function() {
isVisible = false;
});
The “blur” for some reason do not get called (or is called only sometimes)… there is another way to do this?
Use the Page Visibility API. Something like the following should work.