Created
April 5, 2022 21:37
-
-
Save jasonsyoung/a942d3f4b1be5195ba4772a248c8ad0f to your computer and use it in GitHub Desktop.
Wordle cheat
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
// ==UserScript== | |
// @name Show Wordle Solution | |
// @namespace http://nytimes.com | |
// @version 0.1 | |
// @description Wordle cheater | |
// @author jasonsyoung | |
// @match https://www.nytimes.com/games/wordle/index.html | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=nytimes.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const app = document.querySelector('game-app'); | |
if (app.gameStatus !== 'WIN') { | |
const button = document.createElement('button'); | |
button.innerText = 'Show Solution'; | |
button.style.left = button.style.bottom = '1rem'; | |
button.style.zIndex = 10000; | |
button.style.display = 'inline-block'; | |
button.style.border = '0'; | |
button.style.color = 'white'; | |
button.style.fontWeight = '400'; | |
button.style.backgroundColor = '#6AAA64'; | |
button.style.fontSize = '1rem'; | |
button.style.padding = '0.5rem'; | |
button.style.position = 'absolute'; | |
button.style.outline = 'none'; | |
button.style.borderRadius = '0.25rem'; | |
button.style.filter = 'drop-shadow(0.3rem 0.3rem 0.3rem #000)'; | |
button.style.transition = '200ms all'; | |
function onDown() { | |
button.style.transform = 'scale(0.98) translate(0.2rem, 0.2rem)'; | |
button.style.left = '1.2rem'; | |
button.style.bottom = '0.8rem'; | |
button.style.filter = 'drop-shadow(0.1rem 0.1rem 0.1rem #000)'; | |
} | |
function onUp() { | |
button.style.transform = 'scale(1)'; | |
button.style.filter = 'drop-shadow(0.3rem 0.3rem 0.3rem #000)'; | |
} | |
button.addEventListener('mousedown', onDown, false); | |
button.addEventListener('pointerdown', onDown, false); | |
button.addEventListener('touchstart', onDown, false); | |
button.addEventListener('mouseup', onUp, false); | |
button.addEventListener('mouseleave', onUp, false); | |
button.addEventListener('pointerup', onUp, false); | |
button.addEventListener('touchcancel', onUp, false); | |
button.addEventListener('touchend', onUp, false); | |
button.addEventListener('click', event => { | |
const originalText = event.target.innerText; | |
event.target.innerText = app.solution; | |
event.target.style.fontWeight = '900'; | |
setTimeout(() => { | |
event.target.innerText = originalText; | |
event.target.style.fontWeight = '400'; | |
}, 5000); | |
}, false); | |
document.body.appendChild(button); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment