Skip to content

Instantly share code, notes, and snippets.

@njvack
Created June 27, 2025 17:55
Show Gist options
  • Save njvack/aed2fdf82a6a64c14d08b59c319d4715 to your computer and use it in GitHub Desktop.
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
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