Evento do interruptor do navegador JS

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script>
        document.addEventListener("visibilitychange", (event) => {
            if (document.visibilityState == "visible") {
                alert("tab is active")
            } else {
                alert("tab is inactive")
            }
        });
    </script>
Copy Paster