Skip to content

Instantly share code, notes, and snippets.

@gnapse
Created March 14, 2022 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnapse/fced7b8c4ab53f1fb3f961e41c9da32b to your computer and use it in GitHub Desktop.
Save gnapse/fced7b8c4ab53f1fb3f961e41c9da32b to your computer and use it in GitHub Desktop.
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