Spelling bee
andrew@paon.wtfThe New York Times Spelling Bee game is a fun daily game. Here’s one way to ruin it.
let words = await fetch('https://raw.githubusercontent.com/dwyl/english-words/refs/heads/master/words.txt').then(r => r.text()).then(t => t.split('\n'))
let letters = [...document.querySelectorAll('svg.hive-cell')].map(x => x.children[1].textContent)
let re = new RegExp(`^[${letters.join('')}]*${letters[0]}[${letters.join('')}]*$`)
let sleep = ms => new Promise((res, rej) => setTimeout(res, ms))
let send = (key) => document.querySelector('.sb-controls').dispatchEvent(new KeyboardEvent('keydown', {key, 'bubbles': true}));
let matching = words.filter(s => s.length > 3 && s.match(re))
for (let w of matching) {
console.log(w)
for (let c of w.split('')) {
send(c)
await sleep(50)
}
send('Enter')
await sleep(500)
}
Copy this into the browser console and watch it work.
It’s not perfect. The pool of words is way too big. Sometimes the Enter
doesn’t work and it types an extra-long word. Also, it keeps trying to submit guesses after reaching “genius.”
But I don’t plan to fix it. The behavior right now is too charming.