-
-
Save choco-la/a453e71ca3627f84e5da6aa7fc553925 to your computer and use it in GitHub Desktop.
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
(() => { | |
const localTimeLine = document.getElementsByClassName('item-list')[0] | |
const colorCode = '#8BEAC7' | |
const escapeHTML = (string) => { | |
return string | |
.replace(/&/g, '&') | |
.replace(/</g, '<') | |
.replace(/>/g, '>') | |
.replace(/'/g, ''') | |
.replace(/`/g, '`') | |
.replace(/"/g, '"') | |
} | |
const classname = 'status__content status__content--with-action' | |
const onMutation = (mutation) => { | |
mutation.map((dom) => handleNodeList(dom.addedNodes)) | |
} | |
const observer = new MutationObserver(onMutation) | |
const configure = { | |
childList: true | |
} | |
const handleNodeList = (nodelist) => { | |
for (const node of nodelist) { | |
const status = node.getElementsByClassName(classname)[0] | |
// <>などは非対応 | |
const mute = /[うぅ][ゅゆ]/ | |
const match = mute.exec(node.innerText) | |
if (match) { | |
const replaceWith = `<font color="${colorCode}">${escapeHTML(match[0])}</font>` | |
node.innerHTML = node.innerHTML.replace(mute, replaceWith) | |
} | |
} | |
} | |
observer.observe(localTimeLine, configure) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment