How to get a list of YouTube channel emojis?
Matthew Martinez
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?
3 Answers
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'); 0 Not sure if those emojis are available through any API, but, one way you can get those emojis are:
- Click on any of the channel emoji list.
- A new window will appear "for join to that channel".
- Right-click on any of the emojis from the channel > inspect element > get the URLS
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:
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:
- Go to a channel with emotes
- In the chat box, click the 😄 icon near the input box to load the emoji picker. Wait about a second for all images for the channel to load.
- Run the full script below.
frameContext()will ensure that thequerySelector()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 }));