I want to get a list of emojis from youtube live chat (urls or images). For example emojis from this channel. Is there a way to get them using youtube livestreaming api?
I want to get a list of emojis from youtube live chat (urls or images). For example emojis from this channel. Is there a way to get them using youtube livestreaming api?
I wrote a small script to get a list of name / url pairs separated by spaces in the browser console.
Array.from(document.querySelectorAll('img[role="option"][class*="emoji"][aria-label^=":"]').values()).slice(0, 20).map(e => e.getAttribute('aria-label') + ' ' + e.getAttribute('src')).join('\n');
Not sure if those emojis are available through any API, but, one way you can get those emojis are:
The following screenshot shows the results of the mentioned steps:
URL of emojis from YouTube channel ChilledCow:
Additional note: you can change the size of the emoji - by changing the values in the URL:
Example of emoji - :_studynight:
https://yt3.ggpht.com/qKW3_-A6jHFQ5Jqg43ETtH0fdXnxsS8K1YNvz1jlRb9KBa8sRYBEVnucvy54LUU6yWz2kDULLZk=w100-h100-c-k-nd
Change the values of w and h from:
k=w100-h100-c-k-nd
to:
k=w300-h300-c-k-nd
Modified URL - :_studynight
Similar to @Гариша-Галустян, but this will grab all channel emotes and output them as an object with code and src attributes.
Additionally, the chat box is in an iframe, which might not have context for querySelector() to work correctly.
So, to get an object with all channel emotes:
frameContext() will ensure that the querySelector() is using the correct document base.let frameContext = function () {
let frameContext = document.querySelector('ytd-live-chat-frame iframe');
if (frameContext) {
frameContext = frameContext.contentDocument.body;
} else {
frameContext = document.body;
}
return frameContext;
};
Array.from(
frameContext()
.querySelector(
'#categories-wrapper #categories .yt-emoji-picker-renderer'
)
.querySelectorAll('img[role="option"][class*="emoji"][aria-label^=":"]')
.values()
).map((e) => ({ code: e.alt, src: e.src }));