async function sendAdminPush() { const status = document.getElementById("status"); status.textContent = "Step 1: Preparing data..."; const payload = { title: document.getElementById("title").value || "Test Title", body: document.getElementById("body").value || "Test message from tester", image: document.getElementById("image").value || "", count: parseInt(document.getElementById("count").value) || 0 }; status.textContent = "Step 2: Sending to server..."; try { const res =await fetch("/save-sub", { method: "POST", body: JSON.stringify(sub), headers: {"Content-Type": "application/json"} }); status.textContent = "Step 3: Server responded (status " + res.status + ")"; if (res.ok) { const data = await res.json(); status.textContent = `Success! Sent to ${data.sent || 0} / ${data.total || "?"} subscribers`; console.log("Response data:", data); // harmless even if console blocked } else { status.textContent = `Server error: ${res.status} - ${res.statusText}`; const text = await res.text(); status.textContent += " - " + text.substring(0, 100); // show first part of error } } catch (err) { status.textContent = "Fetch failed completely: " + err.message; if (err.name === "TypeError") { status.textContent += " (probably wrong URL or network block)"; } } // Auto-clear after 10 seconds setTimeout(() => { status.textContent = ""; }, 10000); }