Skip to content

Instantly share code, notes, and snippets.

@gosoccerboy5
Created January 9, 2023 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gosoccerboy5/8d026d822a8ea15b410103df80b3cb87 to your computer and use it in GitHub Desktop.
Save gosoccerboy5/8d026d822a8ea15b410103df80b3cb87 to your computer and use it in GitHub Desktop.
Gives you the answers to NYT spelling bee. Paste it in the console once you have the game on your screen
(function() {
const solutions = window.gameData.today.answers;
let list = document.createElement("div");
list.style = `position:fixed;width:15%;height:40%;left:2%;top:30%;
border:5px solid black;z-index:999;padding:5px;background:white;
overflow-y:scroll;resize:both;`;
document.body.append(list);
list.innerHTML = `<h2 style='cursor:all-scroll;user-select:none;font-size:20px;'>Word list</h2>
<hr/><ul></ul>`;
let listEl = list.children[2];
for (solution of solutions) {
let newLi = document.createElement("li");
newLi.title = "Remove word";
newLi.style.cursor = "pointer";
newLi.innerText = solution;
newLi.addEventListener("click", function() {
listEl.removeChild(newLi);
});
listEl.appendChild(newLi);
}
//shamelessly copied and pasted from w3schools
function dragElement() {
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
list.children[0].onmousedown = dragMouseDown;
function dragMouseDown(e) {
e = e || window.event;
e.preventDefault();
// get the mouse cursor position at startup:
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
// call a function whenever the cursor moves:
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
e.preventDefault();
// calculate the new cursor position:
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// set the element's new position:
list.style.top = (list.offsetTop - pos2) + "px";
list.style.left = (list.offsetLeft - pos1) + "px";
}
function closeDragElement() {
// stop moving when mouse button is released:
document.onmouseup = null;
document.onmousemove = null;
}
}
dragElement();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment