Replace Notion's Twemojis with Telegram's Apple (iOS) Emojis
目前為
// ==UserScript==
// @name Notion Apple Emojis
// @version 1.0
// @description Replace Notion's Twemojis with Telegram's Apple (iOS) Emojis
// @author bernzrdo
// @match https://*.notion.so/*
// @match https://*.notion.site/*
// @icon https://i.imgur.com/7lsfUJ8.png
// @license MIT
// @namespace https://greasyfork.org/users/1207477
// ==/UserScript==
function emojiURL(emoji){
if(!emoji) return;
let codes = [];
for(let i = 0; i < emoji.length; i++){
let code = emoji.charCodeAt(i);
if(code == 0xfe0f) continue;
if(code >= 0xd800 && code <= 0xdbff){
let nextCode = emoji.charCodeAt(i + 1);
if(nextCode >= 0xdc00 && nextCode <= 0xdfff){
codes.push(
(code - 0xd800) * 0x400 +
(nextCode - 0xdc00) + 0x10000
);
}
}else if(code < 0xd800 || code > 0xdfff){
codes.push(code);
}
}
codes = codes.map(c=>c.toString(16));
return `https://web.telegram.org/k/assets/img/emoji/${codes.join('-')}.png`;
}
let moddedEmojis = [];
document.body.innerHTML += `<style>
.notion-emoji {
background-size: contain !important;
background-repeat: no-repeat !important;
background-position: center !important;
opacity: 1 !important;
transform: scale(1.2);
}
</style>`;
(function update(){
// remove big emojis
for(let $emoji of document.querySelectorAll('[src^="https://notion-emojis"]')){
$emoji.remove();
}
// clear modded emojis list
moddedEmojis = moddedEmojis.filter(el=>document.contains(el));
for(let $emoji of document.querySelectorAll('.notion-emoji')){
if(moddedEmojis.includes($emoji)) continue;
$emoji.style.background = `url('${emojiURL($emoji.ariaLabel)}')`;
moddedEmojis.push($emoji);
}
requestAnimationFrame(update);
})();