Skip to content

Instantly share code, notes, and snippets.

@TheDcoder
Last active March 3, 2020 05:38
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 TheDcoder/cf3ab2e060144a9a7fd144b36ecd0ae8 to your computer and use it in GitHub Desktop.
Save TheDcoder/cf3ab2e060144a9a7fd144b36ecd0ae8 to your computer and use it in GitHub Desktop.
DOM Focus Tracker Userscript
// ==UserScript==
// @name DOM Focus Tracker (Console)
// @version 0.2
// @description A quick and dirty focus tracker, logs the currently focused element to console
// @include *
// @run-at document-start
// ==/UserScript==
window.addEventListener("focusout", event => console.log(event.relatedTarget === null ? "The webpage has lost focus" : event.relatedTarget), true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment