Skip to content

Instantly share code, notes, and snippets.

@mr5z
Last active April 20, 2025 21:01
Show Gist options
  • Save mr5z/71710f7770a85703a25d21255f7436b8 to your computer and use it in GitHub Desktop.
Save mr5z/71710f7770a85703a25d21255f7436b8 to your computer and use it in GitHub Desktop.
Improvised Twitch emotes
(function() {
const emoteMap = {
"monke": "πŸ’",
"pog": "😲",
"pepega": "🧠❌",
"sadge": "😒",
"OMEGALUL": "🀣",
"KEKW": "πŸ˜‚",
"PeepoHappy": "😊",
"FeelsStrongMan": "πŸ’ͺ",
"catJAM": "🐱🎡",
"PepeHands": "πŸ™ŒπŸΈ",
"PepeLaugh": "😏🐸",
"widepeepoHappy": "πŸ˜€βœ¨"
};
const replaceWithEmotes = (node) => {
if (node.nodeType === Node.TEXT_NODE) {
let original = node.textContent;
for (let keyword in emoteMap) {
let regex = new RegExp(keyword, 'gi'); // global + case insensitive
original = original.replace(regex, emoteMap[keyword]);
}
node.textContent = original;
} else if (node.nodeType === Node.ELEMENT_NODE) {
node.childNodes.forEach(replaceWithEmotes);
}
};
const target = document.querySelector('.chat-list--default');
if (target) {
replaceWithEmotes(target);
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach(replaceWithEmotes);
});
});
observer.observe(target, { childList: true, subtree: true });
console.log('Twitch-style emote replacer is now live! 🐸');
} else {
console.warn('No element found with .chat-list--default');
}
})();
@mr5z
Copy link
Author

mr5z commented Apr 20, 2025

Just paste this in your browser dev console.
What could go wrong 😳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment