forked from FriedChickenButt/youtube-webos
-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
img.emoji { | ||
height: 1em; | ||
width: 1em; | ||
margin: 0 0.05em 0 0.1em; | ||
vertical-align: -0.1em; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import twemoji from '@twemoji/api'; | ||
|
||
import './emoji-font.css'; | ||
|
||
const YT_FORMATTED_STR_TAG = 'yt-formatted-string'; | ||
|
||
const emojiObs = new MutationObserver((mutations) => { | ||
mutations | ||
.flatMap((mut) => Array.from(mut.addedNodes)) | ||
.filter((node) => node instanceof HTMLElement) | ||
.flatMap((elem) => | ||
Array.from( | ||
elem.querySelectorAll(YT_FORMATTED_STR_TAG) as NodeListOf<HTMLElement> | ||
) | ||
) | ||
.forEach((elem) => void twemoji.parse(elem, { size: '72x72' })); | ||
}); | ||
|
||
// twemoji expects the charset to be UTF-8 | ||
if (document.characterSet === 'UTF-8') { | ||
emojiObs.observe(document.body, { childList: true, subtree: true }); | ||
} else { | ||
console.warn('document charset not utf-8. Emoji replacement disabled.'); | ||
} |
This file contains 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