[Solved] If user is not on page, give title notification [closed]


<script>
var timer = null;
function setBlurTitle(num) {
    let n = 1;
    if (num) {
        n = num;
    };
    if (n % 2 == 0) {
        document.title = "come back here";
    } else {
        document.title = "";
    };
    if (timer) {
        clearTimeout(timer);
        timer = null;
    };
    timer = setTimeout(() => {
        n++;
        setBlurTitle(n);
    }, 500);
}
function clearTitle() {
    document.title="normal"
    if (timer) {
        clearTimeout(timer);
        timer = null;
    }

}
window.addEventListener('blur', () => { setBlurTitle() }, false);
window.addEventListener('focus', () => { clearTitle() }, false)

1

solved If user is not on page, give title notification [closed]