diff options
author | Florrie <towerofnix@gmail.com> | 2019-03-23 12:25:28 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2019-03-23 12:25:28 -0300 |
commit | 907ae79780da5b691f835b108663af4de8b1d197 (patch) | |
tree | 381afd9162876d7bfc7d34ec8dec55884cc63d39 /extension | |
parent | 213ef476d5aa27e3590754da52ff1e8c0b48cc38 (diff) |
Update BGM when page loads
Diffstat (limited to 'extension')
-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; |