// ==UserScript== // @name Replace Emojis with System Emojis // @namespace http://tampermonkey.net/ // @version 0.1 // @description Replace all emojis on x.com with macOS system emojis // @author Your Name // @match https://x.com/* // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Helper function to get the macOS system emoji character code for a given Unicode code point function getSystemEmojiCharCode(unicodeCodePoint) { const codePointHex = unicodeCodePoint.codePointAt(0).toString(16); return `&#x${codePointHex};`; } // Function to replace emoji SVG with macOS system emoji function replaceEmojiSVG(node) { if (node.nodeType === Node.ELEMENT_NODE && node.tagName === 'IMG') { const src = node.getAttribute('src'); const alt = node.getAttribute('alt'); if (src.includes('/emoji/v2/svg/') && alt) { const emojiCharCode = getSystemEmojiCharCode(alt); const span = document.createElement('span'); span.innerHTML = emojiCharCode; span.style.fontSize = '16px'; // Adjust the font size as needed node.parentNode.replaceChild(span, node); } } else { for (let child = node.firstChild; child; child = child.nextSibling) { replaceEmojiSVG(child); } } } // Observe DOM mutations and replace emoji SVG const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { if (mutation.type === 'childList') { mutation.addedNodes.forEach(node => { replaceEmojiSVG(node); }); } }); }); observer.observe(document.body, { childList: true, subtree: true }); // Replace emoji SVG in the initial DOM replaceEmojiSVG(document.body); })();