Skip to content

Instantly share code, notes, and snippets.

@TheDcoder
Last active March 3, 2020 05:38
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