はじめに
新作エヴァンゲリオンをすごく楽しみにしているのだが,今一番怖いことはネタバレである.
とくに,Twitterによって偶発的に物語の核心を見てしまうことを最も恐れている.そこで,全人類が無意味なことしか呟けないようにすれば解決するのではないかとひらめき,スクリプトを書いた.
結果
導入方法
スクリプトをコピー
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
function omedeto() { | |
console.log("ome") | |
let spans = document.querySelectorAll("span"); | |
for (let span of spans) { | |
if (span.innerText !== "") { | |
span.innerText = "おめでとう"; | |
} | |
} | |
} | |
function gouinload() { | |
omedeto() | |
interval_id = setInterval(() => { | |
omedeto() | |
}, 200); | |
setTimeout(() => { | |
clearInterval(interval_id) | |
console.log("timeout") | |
}, 5000); | |
} | |
window.onload = gouinload(); | |
window.addEventListener('unload', gouinload); | |
window.addEventListener("scroll", omedeto); |
ChromeにScriptAutoRunnerを導入
ScriptAutoRunnerで設定
新規スクリプト挿入
コピーしたコードを貼り付け
“twitter.com"に設定
スクリプトの実行範囲をtwitterだけにするため
接続
これをしないと,スクリプトが有効にならない
どうやったのか
Twitterのサイト上のspan
要素のinnerText
をすべて「おめでとう」に置換した.
最初はTweetだけを置換しようとしていたがあまりにもTwitterのCSSのクラス名が不可解で抽出がめんどくさかったので、文字要素を入れて要るっぽいspan
要素の全置換に落ち着いた.
不可解なクラス名の様子
人類を補完した感想
早く新作が見に行きたい.