Typefully

How I reverse-engineered "Wordle" 🧠

Avatar

Share

Β β€’Β 

4 years ago

Β β€’Β 

View on X

How I reverse-engineered "Wordle" 🧠
✨ No spoilers here ✨ On Jan 01, 2022 β€” while on vacation, I reverse engineered and hacked the Wordle game. πŸ™ˆ Then I built three little tools for developers and non-developers to solve Wordle however they prefer. Oh, such fun, much luck!
It all started with Inspect Element :) Playing Wordle was fine but I enjoyed building a CLI to solve the damn thing, even more. Looking under the hood I found no relevant API requests. For a while, I was: meh Β―\_(ツ)_/Β―
The AHA moment: Before going down the rabbit hole … I looked for the client-side state. Lo and behold. To my surprise, the solution was right there in the localStorage. πŸ₯³ Haha!!!
The OMG. WTF? BBQ! moment. No network requests. Game’s solution in localStorage. What if there's more. Hint: there was a lot more!! Found an array of 2,315 wordle words in the client-side code. Woohoo! πŸ₯³πŸ₯³πŸ₯³ Look at this beautiful array ↓
Figuring out the algorithm: Skimmed through over 15,625 lines of code, found: πŸ”˜ function to get word index πŸ”˜ function to get start and today's date diff Oh, such fun, much luck! I was golden. Rewrote the algorithm to something like this ↓
#1: Wordle Solved JavaScript Bookmarklet! Make a new bookmark in your browser (right-click on the bookmarks bar and click Add Page β€” use the code below from my blog β†’ Awais.dev/wordle/ ✨ Clicking on the bookmark will show you the solution.
#2: Wordle-solved Chrome Extension Looking for a more fancy solution, with the words listed for yesterday, today, and tomorrow β€” well, it’s your lucky day. I built a Chrome extension called wordle-solved. I love those animations. Yay! πŸ”— github.com/ahmadawais/wordle-solved/
#3: wordle-solved-cli Coz why not?! I didn’t stop there, hehe β€” went ahead and built a CLI using create-node-cli, which tries to mimic the same UI in the terminal for all y’all terminal junkies like me. πŸ”˜ Install it globally `npm i -g wordle-solved-cli` πŸ”˜ Run `wordle` πŸ₯³
Read this story in more detail on my blog: πŸ”— Awais.dev/wordle/ πŸ‘‹ Hello, it's Awais. Nice to e-meet you; I love creating automation tools with JavaScript. Enjoyed this thread? Follow @MrAhmadAwais for more.
Avatar

Ahmad Awais

@MrAhmadAwais

⌘ CEO & Founder @LangbaseInc // @Google Devs Advisory Board // Award-winning @GitHub Star // Ex VP DX Rapid / Quoted by @SatyaNadella "awesome example for devs"