I'm looking for some way of identifying the computer has awaken from sleep mode. I came across this article that uses Date timestamps inside a setInterval to identify that.
It works perfectly in Firefox but not in the other browsers (Chrome, Safari, and Edge). After around 6min of inactivenness (and without focus) the timestamp difference gets greater than the timeout then triggering the awake function.
var TIMEOUT = 20000;
var lastTime = (new Date()).getTime();
setInterval(function() {
var currentTime = (new Date()).getTime();
if (currentTime > (lastTime + TIMEOUT + 2000)) {
// Wake!
}
lastTime = currentTime;
}, TIMEOUT);
Is there any other way to identify that the computer has awaken from sleep mode?