Im trying to do something when a new chat message appears on a youtube live stream in a tampermonkey script.
Im using a DOMNodeInserted event on a div with the id "chat-messages"
The problem is: im not able to get the id of the element (undefined) but it's getting printed in the console correctly. Its also not possible to get the class attribute using jquery.
Code:
$("#chat-messages").on('DOMNodeInserted', function(e) {
var VanillaElement = e.target;
var JqueryElement = $(VanillaElement);
if(JqueryElement.is("yt-live-chat-text-message-renderer")){
console.log("added chat message");
console.log(VanillaElement);
console.log(VanillaElement.id);
console.log(JqueryElement.attr("class"));
}
});
Here is a screenshot for better understanding: