Last active
December 8, 2019 20:35
-
-
Save 8q/e69016699f4ed72f32574801b7eac799 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 texts = [ | |
"俺の勝ち。", | |
"俺の勝ちだが?", | |
"お前の負け。", | |
"お前の負けだが?", | |
"I win.", | |
"You lose." | |
] | |
const getRandomText = () => texts[Math.floor(Math.random() * texts.length)] | |
const target = document.body | |
// 既にあるやつを置き換える。 | |
target.querySelectorAll("article .tweet-text") | |
.forEach(element => element.textContent = getRandomText()) | |
// target以下に対する変化を監視 | |
const observer = new MutationObserver(mutations => { | |
const articleNodes = mutations | |
.flatMap(mutation => Array.from(mutation.addedNodes)) | |
.filter(node => node.nodeName.toLowerCase() === "article") | |
articleNodes.forEach(node => { | |
const element = node.querySelector(".tweet-text") | |
if (element) { | |
element.textContent = getRandomText() | |
} | |
}) | |
}) | |
observer.observe(target, { childList: true, subtree: true }) | |
})() |
This file contains hidden or 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 thinkingUnko = str => `${str} | |
 ̄ ̄ヽ、 _ノ ̄ ̄ ̄ ̄ ̄ | |
`'ー '´ | |
○ と思う | |
O 💩であった。 | |
👑 | |
(💩💩💩) | |
(💩👁💩👁💩) | |
(💩💩💩👃💩💩💩) | |
(💩💩💩💩👄💩💩💩💩) | |
` | |
const target = document.body | |
// 既にあるやつを置き換える。 | |
target.querySelectorAll("article .tweet-text") | |
.forEach(element => element.textContent = thinkingUnko(element.textContent)) | |
// target以下に対する変化を監視 | |
const observer = new MutationObserver(mutations => { | |
const articleNodes = mutations | |
.flatMap(mutation => Array.from(mutation.addedNodes)) | |
.filter(node => node.nodeName.toLowerCase() === "article") | |
articleNodes.forEach(node => { | |
const element = node.querySelector(".tweet-text") | |
if (element) { | |
element.textContent = thinkingUnko(element.textContent) | |
} | |
}) | |
}) | |
observer.observe(target, { childList: true, subtree: true }) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment