I'm building a chrome extension who should get when browser is focused or not. I'm using a background script defined in my mainfest.json. Something like this:
chrome.windows.onFocusChanged.addListener(function(window){
if (window == chrome.windows.WINDOW_ID_NONE) {
//Do something
}
});
But the event isn't always fired on focus change. I've followed this question and its relative answer to the Google Issue Forum here.
From google docs
Fired when the currently focused window changes. Will be chrome.windows.WINDOW_ID_NONE if all chrome windows have lost focus.
From issue answers Jan 20, 2015
[...]chrome does not fire onfocusChange event in every possible situation, only between chrome windows or between another app if new tab is currently active tab. [...]it looks like dev's not interested currently in chrome.windows API
My question. Is it actually possible catch anytime the browser has focus in a chrome extension?
Thanks in advance.