Skip to content

Instantly share code, notes, and snippets.

@kirantambe
Last active May 16, 2019 11:29
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 kirantambe/ad92043dd86bf577324b38a3b21622ff to your computer and use it in GitHub Desktop.
Save kirantambe/ad92043dd86bf577324b38a3b21622ff to your computer and use it in GitHub Desktop.
Create a bookmarklet and click it or paste in console show song name as notification when song changes
javascript: (function () {
if (window.location.host == 'music.youtube.com') {
Notification.requestPermission().then(function (permission) {
if (permission == 'granted') {
document.querySelector('#progress-bar.ytmusic-player-bar').addEventListener('value-change', function (event) {
if(event.srcElement.value == 1) {
new Notification(document.querySelector('.title.ytmusic-player-bar').textContent, {
icon: document.querySelector('img.ytmusic-player-bar').src,
body: document.querySelector('.subtitle.ytmusic-player-bar').textContent.trim().split('•')[0]
});
}
});
}
});
} else {
alert('Use this only when the youtube music tab is active');
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment