Created
March 14, 2022 16:55
-
-
Save gnapse/fced7b8c4ab53f1fb3f961e41c9da32b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debugFocus(turnOn) { | |
if (turnOn && window.debugFocusInterval) { | |
console.log("debugFocus: already on"); | |
return; | |
} | |
if (!turnOn && !window.debugFocusInterval) { | |
console.log("debugFocus: already off"); | |
return; | |
} | |
if (window.debugFocusInterval) { | |
clearTimeout(window.debugFocusInterval); | |
window.debugFocusInterval = null; | |
console.log("debugFocus: off"); | |
return; | |
} | |
let activeElement = null; | |
window.debugFocusInterval = setInterval(() => { | |
if (activeElement != document.activeElement) { | |
activeElement = document.activeElement; | |
console.log("activeElement", activeElement); | |
} | |
}, 1000); | |
console.log("debugFocus: on"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment