diff options
-rw-r--r-- | extension/interactive-bgm.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/extension/interactive-bgm.js b/extension/interactive-bgm.js index 1d29d06..773391f 100644 --- a/extension/interactive-bgm.js +++ b/extension/interactive-bgm.js @@ -1,5 +1,19 @@ -window.addEventListener('focus', () => { +const sendHostname = () => { browser.runtime.sendMessage({hostname: location.hostname}); +}; + +window.addEventListener('focus', sendHostname); + +document.addEventListener('visibilitychange', () => { + if (!document.hidden) { + sendHostname(); + } +}); + +window.addEventListener('load', () => { + if (!document.hidden) { + sendHostname(); + } }); let hasShownCreateTrack = false; |