Added Amazon Smile links to the site list, and added a listener for tab changes so the music properly stops if the shopping tab is changed or closed.

This commit is contained in:
Will Minnis
2020-09-12 15:57:55 -07:00
parent 1e604e0d2b
commit 4ee0a221cd
2 changed files with 32 additions and 3 deletions

View File

@@ -31,6 +31,21 @@ chrome.tabs.onUpdated.addListener(function (tabId, changeInfo) {
})
})
// Detect shopping tab becoming inactive/closed, if the domain matches a shopping site, play music
chrome.tabs.onActivated.addListener(function(activeInfo) {
chrome.tabs.get(activeInfo.tabId, function(tab) {
var url = new URL(tab.url)
var domain = url.hostname.toString().replace('www.','')
console.log(domain)
if (!siteList.includes(domain)) {
themeAudio.pause()
}
else {
themeAudio.play()
}
})
})
// Show notification on extension install
chrome.runtime.onInstalled.addListener(function() {
chrome.notifications.create({
@@ -39,4 +54,4 @@ chrome.runtime.onInstalled.addListener(function() {
'title': 'Wii Shop Music extension installed!',
'message': 'The Wii Shop theme will now play when you visit shopping websites.'
})
})
})