Last active
April 14, 2016 18:38
-
-
Save carlin-q-scott/ed558aa18b5bbf2d27c1284b8f542025 to your computer and use it in GitHub Desktop.
Method for notifying user of new tracks on Pandora.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Uses https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver and https://developer.mozilla.org/en-US/docs/Web/API/notification