-
-
Save Mellen/799589b43004fa31fd108afc8fc42a40 to your computer and use it in GitHub Desktop.
Show the possible solutions for wordle
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
// ==UserScript== | |
// @name wordle help | |
// @version 1 | |
// @match https://www.powerlanguage.co.uk/wordle/ | |
// @grant GM.xmlHttpRequest | |
// @run-at document-end | |
// ==/UserScript== | |
const wordlist = document.createElement('select'); | |
wordlist.setAttribute('multiple', 'true'); | |
wordlist.setAttribute('style', 'position:absolute;top:0;left:0;height:512px'); | |
GM.xmlHttpRequest( | |
{ | |
method: "GET", | |
url: "https://www.powerlanguage.co.uk/wordle/main.e65ce0a5.js", | |
onload: function(response) | |
{ | |
let mainjs = response.responseText; | |
let startIndex = mainjs.indexOf('=["')+1; | |
let endIndex = mainjs.indexOf('"]', startIndex)+2; | |
let possiblewords = JSON.parse(mainjs.substring(startIndex, endIndex)); | |
for(let pos of possiblewords) | |
{ | |
const opt = document.createElement('option'); | |
opt.textContent = pos; | |
wordlist.appendChild(opt); | |
} | |
document.body.appendChild(wordlist); | |
} | |
}); | |
const game = document.querySelector("game-app") | |
game.addEventListener('click', function(e) | |
{ | |
if(e.originalTarget.dataset['key'] == '↵') | |
{ | |
const kbd = e.originalTarget.parentElement.parentElement; | |
const absent = [...kbd.querySelectorAll('button[data-state="absent"]')].reduce((abs, button) => abs += button.dataset['key'], ''); | |
let rems = []; | |
for(let opt of wordlist.options) | |
{ | |
for(let c of absent) | |
{ | |
if(opt.textContent.includes(c)) | |
{ | |
if(!rems.includes(opt)) | |
{ | |
rems.push(opt) | |
} | |
break; | |
} | |
} | |
} | |
for(let opt of rems) | |
{ | |
wordlist.removeChild(opt); | |
} | |
const contains = [...kbd.querySelectorAll('button[data-state="present"], button[data-state="correct"]')].reduce((abs, button) => abs += button.dataset['key'], ''); | |
rems = []; | |
for(let opt of wordlist.options) | |
{ | |
for(let c of contains) | |
{ | |
if(!opt.textContent.includes(c)) | |
{ | |
if(!rems.includes(opt)) | |
{ | |
rems.push(opt) | |
} | |
break; | |
} | |
} | |
} | |
for(let opt of rems) | |
{ | |
wordlist.removeChild(opt); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment