Last active
April 20, 2025 21:01
-
-
Save mr5z/71710f7770a85703a25d21255f7436b8 to your computer and use it in GitHub Desktop.
Improvised Twitch emotes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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'); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just paste this in your browser dev console.
What could go wrong π³