Last active
February 17, 2022 02:46
-
-
Save bellbind/8ef506a5f267a7b5656cb8e03e528584 to your computer and use it in GitHub Desktop.
[deno] print wordle answer of today
This file contains 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
void(fetch(document.querySelector("script[src^=main]").src).then(r=>r.text()).then(c=>JSON.parse(c.match(/(\[("[a-z]{5}",)*"[a-z]{5}"\])/)[1])).then(w=>alert(w[((new Date().setHours(0,0,0,0)-new Date("2021-6-19"))/864e5)%w.length]))) |
This file contains 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
<html> | |
<head> | |
<title>wordle answer bookmarklet</title> | |
</head> | |
<body> | |
Drag <a style="border: solid transparent; border-radius: 5px; padding: 5px; background-color: gray; color: white;" | |
href='javascript:void(fetch(document.querySelector("script[src^=main]").src).then(r=>r.text()).then(c=>JSON.parse(c.match(/(\[("[a-z]{5}",)*"[a-z]{5}"\])/)[1])).then(w=>alert(w[((new Date().setHours(0,0,0,0)-new Date("2021-6-19"))/864e5)%w.length])))' | |
>Wordle answer</a> into your bookmark bar | |
</body> | |
</html> |
This file contains 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
// deno run --allow-net wordle-answer.js | |
import {JSDOM} from "https://jspm.dev/npm:jsdom-deno"; | |
const url = "https://www.nytimes.com/games/wordle/index.html"; | |
const {document} = new JSDOM(await fetch(url).then(r => r.text()), {url}).window; | |
const script = document.querySelector("script[src^=main]").src; | |
const code = await fetch(script).then(r => r.text()); | |
const [solutions, accepts] = [...code.matchAll(/(\[("[a-z]{5}",)*"[a-z]{5}"\])/g)].map(m => JSON.parse(m[1])); | |
const index = (new Date().setHours(0, 0, 0, 0) - new Date("2021-6-19")) / (24 * 60 * 60 * 1000); | |
console.log(solutions[index % solutions.length]); | |
Deno.exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bookmarklet page: https://gist.githack.com/bellbind/8ef506a5f267a7b5656cb8e03e528584/raw/wordle-answer-bookmarklet.html