Last active
March 29, 2021 09:55
-
-
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.
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
(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