Notion Apple Emojis

Replace Notion's Twemojis with Telegram's Apple (iOS) Emojis

  1. // ==UserScript==
  2. // @name Notion Apple Emojis
  3. // @version 1.2
  4. // @description Replace Notion's Twemojis with Telegram's Apple (iOS) Emojis
  5. // @author bernzrdo
  6. // @match https://*.notion.so/*
  7. // @match https://*.notion.site/*
  8. // @icon https://i.imgur.com/7lsfUJ8.png
  9. // @license MIT
  10. // @namespace https://greasyfork.org/users/1207477
  11. // ==/UserScript==
  12.  
  13. function emojiURL(emoji){
  14. if(!emoji) return;
  15.  
  16. if(emoji == '♀️') return 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Female_Sign_Emoji_%28Unofficial_Apple_Emoji%29.svg/64px-Female_Sign_Emoji_%28Unofficial_Apple_Emoji%29.svg.png';
  17. if(emoji == '♂️') return 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/Male_Sign_Emoji_%28Unofficial_Apple_Emoji%29.svg/64px-Male_Sign_Emoji_%28Unofficial_Apple_Emoji%29.svg.png';
  18.  
  19. let codes = [];
  20.  
  21. for(let i = 0; i < emoji.length; i++){
  22.  
  23. let code = emoji.charCodeAt(i);
  24. if(code == 0xfe0f) continue;
  25.  
  26. if(code >= 0xd800 && code <= 0xdbff){
  27.  
  28. let nextCode = emoji.charCodeAt(i + 1);
  29.  
  30. if(nextCode >= 0xdc00 && nextCode <= 0xdfff){
  31. codes.push(
  32. (code - 0xd800) * 0x400 +
  33. (nextCode - 0xdc00) + 0x10000
  34. );
  35. }
  36.  
  37. }else if(code < 0xd800 || code > 0xdfff){
  38. codes.push(code);
  39. }
  40.  
  41. }
  42.  
  43. codes = codes.map(c=>c.toString(16).padStart(4, '0'));
  44.  
  45. return `https://web.telegram.org/k/assets/img/emoji/${codes.join('-')}.png`;
  46.  
  47. }
  48.  
  49. document.body.innerHTML += `<style>
  50.  
  51. .notion-emoji {
  52. background-size: contain !important;
  53. background-repeat: no-repeat !important;
  54. background-position: center !important;
  55. opacity: 1 !important;
  56. transform: scale(1.2);
  57. }
  58.  
  59. </style>`;
  60.  
  61. (function update(){
  62.  
  63. // remove big emojis
  64. for(let $emoji of document.querySelectorAll('[src^="https://notion-emojis"]')){
  65. $emoji.remove();
  66. }
  67.  
  68. for(let $emoji of document.querySelectorAll('.notion-emoji')){
  69. let [emoji] = $emoji.alt.split(/\s+/);
  70. $emoji.style.background = `url('${emojiURL(emoji)}')`;
  71. }
  72.  
  73. requestAnimationFrame(update);
  74. })();