Skip to content

Instantly share code, notes, and snippets.

@carlin-q-scott
Last active April 14, 2016 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlin-q-scott/ed558aa18b5bbf2d27c1284b8f542025 to your computer and use it in GitHub Desktop.
Save carlin-q-scott/ed558aa18b5bbf2d27c1284b8f542025 to your computer and use it in GitHub Desktop.
Method for notifying user of new tracks on Pandora.com
function notifyNewTrack(mutation){
new Notification("Now Playing", {
body: document.querySelector('.trackData').innerText
})
}
Notification.requestPermission() //normally you'd handle the response and accept rejection but whatev's.
var currentTrackObserver = new MutationObserver(notifyNewTrack)
currentTrackObserver.observe(document.querySelector('#trackInfoContainer'), {
childList: true,
characterData: true,
subtree: true
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment