Skip to content

Instantly share code, notes, and snippets.

@botatooo
Created March 14, 2023 01:11
Show Gist options
  • Save botatooo/59b455d947c6c4ff30ce10d920dddb9e to your computer and use it in GitHub Desktop.
Save botatooo/59b455d947c6c4ff30ce10d920dddb9e to your computer and use it in GitHub Desktop.
Add a timestamp on the Twitch stream itself
(() => {
const liveTime = document.querySelector('.live-time');
const style = document.createElement("style");
style.id = 'on-video-time-style';
style.textContent = `#on-video-time {
position: absolute;
padding: .5rem;
top: 0;
right: .3rem;
z-index: 9999;
color: white;
font-size: 3rem;
font-weight: bold;
text-shadow: 0 0 2px black;
}`;
document.head.appendChild(style);
const onVideoTime = document.createElement('div');
onVideoTime.id = 'on-video-time';
onVideoTime.textContent = liveTime.textContent;
const videoContainer = document.querySelector(".video-ref");
videoContainer.insertBefore(onVideoTime, videoContainer.children[0])
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (mutation.type === 'characterData') {
onVideoTime.textContent = mutation.target.textContent
}
}
});
observer.observe(liveTime, {
characterData: true,
subtree: true
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment