Some websites stop working (for example, playing music) if one moves from one tab to another. Question: Is it possible for the client to stop this behaviour?
There are multiple ways to check if the current browser tab is focused. One can use document.hasFocus()
or window.addEventListener('focus', function)
, for example. The visibilitychange
or blur
events aren't cancelable, so Event.stopPropagation
wouldn't work. But is there any other way to stop their propagation? (For example, could an addon break the way the blur
event works and not make it dispatch?)
Or is there a way to simulate a tab having focus via the JS console? For example, by toggling a checkbox in the Web Console or by constantly retriggering a focus
event after the tab loses focus? (Or maybe could tampermonkey force set the read-only document.visibilityState
always to visible
?)
Regarding the question being closed: This question is not the same as Is there a way to detect if a browser window is not currently active?, it's asking from the opposite direction: that question asks how can one detect changes in focus, this one asks how can one avoid that detection