Skip to content

Instantly share code, notes, and snippets.

@antichris
Last active March 29, 2021 09:55
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 antichris/93dfc6ed2beb4906e2e1292c6af3649c to your computer and use it in GitHub Desktop.
Save antichris/93dfc6ed2beb4906e2e1292c6af3649c to your computer and use it in GitHub Desktop.
Separate the chats of different livestream events in a YouTube Live Chat history (as exported by Google Takeout) with buttons that embed the respective streams.
(d=>{
const ce = n=>d.createElement(n), ac = (p,c)=>p.appendChild(c), an = (p,n)=>ac(p, ce(n))
let p;
[].forEach.call(d.querySelectorAll('li'), e=>{
a = e.querySelector('a');
if (!a || a.href == p) { return; }
p = a.href;
const t = ce('li'), b = an(an(e.parentNode.insertBefore(t, e), 'h1'), 'button')
ac(b, document.createTextNode(p.split('?v=')[1]));
b.addEventListener('click', ev=>b.outerHTML = '<iframe width=560 height=315 src=https://www.youtube.com/embed/' + b.textContent
+ ' frameborder=0 allow="accelerometer;autoplay;clipboard-write;encrypted-media;gyroscope;picture-in-picture" allowfullscreen></iframe>')
})
})(document)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment