Download this file
| 1 | // The connect page: while the code waits, post "Check again" every five |
| 2 | // seconds (Equipo's shortest interval) and move on when the state changes. |
| 3 | // Without this script the person presses Check again themselves. |
| 4 | |
| 5 | const form = document.querySelector("form[data-connect-check]"); |
| 6 | if (form) { |
| 7 | setInterval(async () => { |
| 8 | if (document.hidden) return; |
| 9 | try { |
| 10 | const res = await fetch(form.action, { |
| 11 | method: "POST", |
| 12 | headers: { Accept: "application/json" }, |
| 13 | body: new URLSearchParams(new FormData(form)), |
| 14 | }); |
| 15 | const out = await res.json(); |
| 16 | if (res.ok && out.state !== "pending") location.assign(out.location); |
| 17 | } catch { |
| 18 | // Equipo or Base is unreachable: try again on the next tick. |
| 19 | } |
| 20 | }, 5000); |
| 21 | } |
| 22 | |