function colab_timer() { console.log("таймер колаба"); let colab_inprogress = ` `; let startTime; let timeout; function updateTimer(el) { const a = (i) => (i < 10 ? "0" + i : i); const b = (x) => Math.floor(x); let c = b(Date.now() / 1000) - startTime; let h = a(b(c / 3600)); let m = a(b((c / 60) % 60)); let s = a(b(c % 60)); if (c > 298 && c < 315) { el.innerText = "Обычно в это время вылазит капча, проверь вкладку колаба (" + h + ":" + m + ":" + s + ")"; } else { el.innerText = h + ":" + m + ":" + s; } if (c % 30 == 0) { refreshTimer(el, true); return; } timeout = setTimeout(() => updateTimer(el), 1000); } const refreshTimer = (timerEl, notext = false) => { if (timeout) { clearTimeout(timeout); timeout = null; } if (!notext) { timerEl.innerText = "подключение..."; timerEl.style.color = "#ff9f00"; } fetch("file=static/launch.txt", { cache: "no-store" }) .then((response) => { if (response.status == 404) { timerEl.innerText = "колаб выключился!"; timerEl.style.color = "red"; const audioSrc = "/content/a1111/extensions/Timer/Timer.mp3"; // путь к аудиофайлу const audio = document.createElement("audio"); audio.src = audioSrc; audio.style.display = "none"; document.body.appendChild(audio); audio.play().catch((error) => console.log("звук не удалось воспроизвести", error)); return; } else if (response.status != 404) { img.innerHTML = colab_inprogress; timerEl.style.color = "#ff9f00"; } response.text().then((text) => { startTime = parseInt(text); updateTimer(timerEl); }); }) .catch((err) => { console.log