Last active
November 24, 2022 23:11
-
-
Save noevidenz/8f2e46bd06b413008d40239ec028fa10 to your computer and use it in GitHub Desktop.
A quick script to add Discord spoiler tags around your Wordle result for the day.
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
/** | |
* Reads your Wordle result from stdin and logs to stdout. | |
* | |
* Usage on macOS: `alias spoilerdle="pbpaste | node ~/bin/spoilerdle.js | pbcopy"` | |
*/ | |
const fs = require('fs') | |
const light = "⬜" | |
const dark = "⬛" | |
const input = fs.readFileSync(0, 'utf-8') | |
const lines = input.split("\n") | |
let header = lines.shift() | |
const gap = lines.shift() | |
// figure out if light or dark mode | |
let mode = light | |
if (lines.some((line) => line.includes(dark))) { | |
mode = dark | |
} | |
// pad to 6 lines | |
let output = lines | |
.slice(0, input.includes('nyt.com') ? lines.length - 2 : lines.length) // Fix thanks to @ttam | |
.concat(Array(6).fill(Array(5).fill(mode).join(''))) | |
.slice(0, 6) | |
// mask header | |
header = header.replace(/([0-6X]\/6)/, '||$1||') | |
console.log(header, "\n", gap) | |
output.map((line) => console.log(`||${line}||`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment