make pets once per page load

This commit is contained in:
zyl 2024-06-25 16:38:35 -07:00
parent e081dbfe59
commit da4ae7f9cc
No known key found for this signature in database

View file

@ -1,8 +1,6 @@
(function () {
"use strict";
const DEBOUNCE_TIMER = 1500;
const url = document.body.classList.contains("debug")
? "http://127.0.0.1:8787/api/pet"
: "https://cf.zyllian.workers.dev/api/pet";
@ -18,7 +16,7 @@
petButton.addEventListener("click", async () => {
petButton.disabled = true;
setTimeout(() => (petButton.disabled = false), DEBOUNCE_TIMER);
petButton.innerText = "thanks! <3";
const r = await (await fetch(url, { method: "post" })).json();
if (r.count) {
count.innerText = r.count;