Created
September 23, 2019 22:18
-
-
Save myfonj/c7426eb31da5f901ecc5ca762b41fbac to your computer and use it in GitHub Desktop.
youtube set scrobbling POC
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(){ | |
// document.getElementById('more').dispatchEvent(new Event('click')); | |
// seems it is not necessary after all; description is already present | |
let c = document.getElementById('description'); | |
var ts = Array.from(c.querySelectorAll('a[href^="/"][href*="&t="]')) | |
.map( | |
a=>[ | |
a.getAttribute('href').match(/&t=([^&]*)/)[1], // seconds | |
a.nextSibling.textContent.trim().split('\n')[0] // title | |
] | |
); | |
console.info(ts) | |
})() | |
// https://www.youtube.com/watch?v=0Y2UzCL0ZGI (terrible performance, but nice "Play list:" section) | |
// https://github.com/web-scrobbler/web-scrobbler/issues/122 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment