Last active
May 16, 2019 11:29
-
-
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
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
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