dkl9 commited on 2025-361 19:16:14
Showing 1 changed files, with 9 additions and 5 deletions.
| ... | ... |
@@ -16,13 +16,17 @@ switch (host) {
|
| 16 | 16 |
puzzleNum = parseInt(r.url.match(/n=(\d+)/)[1]); |
| 17 | 17 |
target = (await r.text()).trim().split(" ");
|
| 18 | 18 |
window.dispatchEvent(new Event("targetReady"));
|
| 19 |
- const score = localStorage.getItem("score").split("\n");
|
|
| 20 |
- if (playedToday(score)) {
|
|
| 19 |
+ const score = playedToday(); |
|
| 20 |
+ if (score) {
|
|
| 21 | 21 |
const [g, m] = score[0].split(" ")[2].split("/");
|
| 22 | 22 |
const note = elemText(`You already played today and `, "section"); |
| 23 | 23 |
note.textContent += (g <= m) ? `got it in ${g} guess${g == 1 ? "" : "es"}` : `didn't figure it out`;
|
| 24 | 24 |
note.textContent += ". Come back tomorrow. Full score on clipboard. "; |
| 25 | 25 |
note.classList.add("side");
|
| 26 |
+ const b = elemText("Copy again", "button");
|
|
| 27 |
+ b.type = "button"; |
|
| 28 |
+ b.addEventListener("click", () => navigator.clipboard.writeText(boast));
|
|
| 29 |
+ note.append(b); |
|
| 26 | 30 |
grid.parentElement.before(note); |
| 27 | 31 |
navigator.clipboard.writeText(score.join("\n"));
|
| 28 | 32 |
} |
| ... | ... |
@@ -53,9 +57,8 @@ if (gotitButton) {
|
| 53 | 57 |
function playedToday(s) {
|
| 54 | 58 |
if (puzzleNum == 0) |
| 55 | 59 |
return false; |
| 56 |
- if (!s) |
|
| 57 | 60 |
s = (localStorage.getItem("score") || "").split("\n");
|
| 58 |
- return s[0] && s[0].split(" ")[1] == puzzleNum;
|
|
| 61 |
+ return (s[0] && s[0].split(" ")[1] == puzzleNum) ? s : null;
|
|
| 59 | 62 |
} |
| 60 | 63 |
|
| 61 | 64 |
function elemText(s, e = "p") {
|
| ... | ... |
@@ -266,7 +269,8 @@ function winMessage() {
|
| 266 | 269 |
b.type = "button"; |
| 267 | 270 |
b.addEventListener("click", () => navigator.clipboard.writeText(boast));
|
| 268 | 271 |
w.append(b); |
| 269 |
- w.append("\nCome back tomorrow for the next function.");
|
|
| 272 |
+ w.append(elemText("", "br"));
|
|
| 273 |
+ w.append("Come back tomorrow for the next function.");
|
|
| 270 | 274 |
w.classList.add("side");
|
| 271 | 275 |
grid.parentElement.before(w); |
| 272 | 276 |
} |
| 273 | 277 |