Tab hint effect

See the JavaScript code that is needed to check if the current tab is focused by the user, and to alter the title and favicon if it's not (to hint the user to come back).

"use strict";
const onVisibilityChange = () => {
    const documentTitle = document.querySelector('title');
    const documentIcon = document.querySelector('[type="image/x-icon"]');

    if (document.visibilityState === 'hidden') {
        documentTitle.innerHTML = 'Please come back!';
        documentIcon.href = setSvg('📣');
    } else {
        documentTitle.innerHTML = 'A very interesting website';
        documentIcon.href = setSvg('🎯');
    }
};
document.addEventListener('visibilitychange', onVisibilityChange, false);

function setSvg(icon) {
    return `data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>${icon}</text></svg>`;
}