Skip to content

Instantly share code, notes, and snippets.

@j-f1
Last active December 1, 2020 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j-f1/84f97cfdab222caa7bf8ca3c66a375d0 to your computer and use it in GitHub Desktop.
Save j-f1/84f97cfdab222caa7bf8ca3c66a375d0 to your computer and use it in GitHub Desktop.
Replace the emoji on the Messenger website with the platform’s native ones
// ==UserScript==
// @name Messenger Native Emoji
// @namespace http://jedfox.com/
// @version 1.0
// @description Use native emoji on Messenger
// @author Jed Fox
// @match *://*.messenger.com/*
// @grant GM_addScript
// ==/UserScript==
(function() {
'use strict';
const codePointRe = /([0-9a-f]+(?:_[0-9a-f]+)*)\.png$/
function parse(src) {
try {
const [, codes] = codePointRe.exec(src)
return codes.split("_").map(c => String.fromCodePoint(parseInt(c, 16))).join("")
} catch (err) {
return "�"
}
}
function run() {
document.querySelectorAll('img[src*="emoji.php"]').forEach(image => {
let emoji = parse(image.src) + '\u{FE0F}'
let { height } = image.getBoundingClientRect()
image.outerHTML = `<span ${height ? `style="font-size: ${height}px"` : ''}>${emoji}</span>`
})
}
run()
let currentUrl = document.location.href
const observer = new MutationObserver(run);
const target = document.body;
const config = { childList: true, subtree: true };
observer.observe(target, config);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment