Skip to content

Instantly share code, notes, and snippets.

@8q
Last active December 8, 2019 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 8q/e69016699f4ed72f32574801b7eac799 to your computer and use it in GitHub Desktop.
Save 8q/e69016699f4ed72f32574801b7eac799 to your computer and use it in GitHub Desktop.
(() => {
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 })
})()
(() => {
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