Skip to content

Instantly share code, notes, and snippets.

@gdoteof
Created November 2, 2018 01:47
Show Gist options
  • Save gdoteof/087dc983e408a96b43e7053cf86c143f to your computer and use it in GitHub Desktop.
Save gdoteof/087dc983e408a96b43e7053cf86c143f to your computer and use it in GitHub Desktop.
youtube chat logger
function lastMessage(){
let a = document.getElementsByTagName('yt-live-chat-text-message-renderer');
return {
user: a[a.length-1].getElementsByTagName('yt-live-chat-author-chip')[0].innerText,
message: a[a.length-1].querySelector('#message').innerText,
}
}
window.ggCacheChat = {user:'',message:''}
window.ggCacheStore= []
function sample(){
var last = window.ggCacheChat;
var check = lastMessage();
if (last.user !== check.user || last.message !== check.message) {
window.ggCacheStore.push(check)
console.log("adding ", check);
}
window.ggCacheChat = check;
}
var myInterval = window.setInterval(sample, 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment