Created
June 27, 2025 17:55
-
-
Save njvack/aed2fdf82a6a64c14d08b59c319d4715 to your computer and use it in GitHub Desktop.
Paste this in the console to get outlines and notifications of focus change events on your page
This file contains hidden or 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
document.addEventListener('focusin', (e) => { | |
// Remove previous highlight | |
document.querySelectorAll('.debug-focus').forEach(el => el.classList.remove('debug-focus')); | |
// Add highlight to current element | |
e.target.classList.add('debug-focus'); | |
console.log(e.target); | |
}); | |
// Add CSS for the highlight | |
const style = document.createElement('style'); | |
style.textContent = '.debug-focus { outline: 3px solid red !important; }'; | |
document.head.appendChild(style) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment