Discussions » Creation Requests
How to make a site/tab think it's still in focus?
Depending on the site you'll have to spoof the events/properties that it uses. The most common ones are visibilitychange
, pagehide
, blur
so you can start with something like this:
// @run-at document-start
.............
const ael = unsafeWindow.addEventListener;
unsafeWindow.addEventListener = unsafeWindow.document.addEventListener = function(name) {
if (!/^(visibilitychange|pagehide|blur)$/i.test(name)) {
return ael.apply(this, arguments);
}
};
You may need to spoof document.hasFocus() too.
sorry, i dont know how to code, what are the parts i need to replace?
Does someone have a code i can use so the site/tab thinks it is still in focus while i go to another site/app?