Skip to content

Instantly share code, notes, and snippets.

@myfonj
Created September 23, 2019 22:18
Show Gist options
  • Save myfonj/c7426eb31da5f901ecc5ca762b41fbac to your computer and use it in GitHub Desktop.
Save myfonj/c7426eb31da5f901ecc5ca762b41fbac to your computer and use it in GitHub Desktop.
youtube set scrobbling POC
(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