File size: 4,791 Bytes
6974fc5
 
8b8d601
 
 
 
 
 
6974fc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eacbd11
6974fc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function colab_timer() {
  console.log("таймер колаба");
  let colab_inprogress = `<svg id="colab" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 96 58" shape-rendering="geometricPrecision" text-rendering="geometricPrecision">
  <style>
  #clb_c {animation: clb_c_anim 1000ms linear infinite normal forwards}@keyframes clb_c_anim { 0% {transform: translate(67.5px,28.960001px) rotate(0deg)} 100% {transform: translate(67.5px,28.960001px) rotate(-360deg)}} #clb_o {animation: clb_o_anim 1000ms linear infinite normal forwards}@keyframes clb_o_anim { 0% {transform: translate(28.520002px,28.96px) rotate(0deg)} 100% {transform: translate(28.520002px,28.96px) rotate(360deg)}}
  </style>
  <defs><linearGradient id="clb_str" x1="20.151062" y1="20.164003" x2="-20.154037" y2="-20.141096" spreadMethod="pad" gradientUnits="userSpaceOnUse" gradientTransform="translate(0 0)"><stop id="clb_str-0" offset="0%" stop-color="#e8710a"/><stop id="clb_str-1" offset="50%" stop-color="#ec7e08"/><stop id="clb_str-2" offset="50%" stop-color="#f49b03"/><stop id="clb_str-3" offset="100%" stop-color="#f9ab00"/></linearGradient></defs><g id="clb_c" transform="translate(67.5,28.960001) rotate(0)"><circle id="colab-u-o" r="21.5" transform="translate(0,-0.000001)" fill="none" stroke="url(#clb_str)" stroke-width="14" stroke-miterlimit="10"/></g><g id="colab-u-c"><g id="colab-s-g1" clip-path="url(#colab-s-clippath1)"><g id="clb_o" transform="translate(28.520002,28.96) rotate(0)"><g id="colab-s-g2" transform="translate(-28.520002,-28.96)"><g id="colab-u-gradirnt_c"><path id="colab-s-path1" d="M48.68,49.11l-9.9-9.9c2.74-2.74,4.24-6.38,4.24-10.25s-1.51-7.52-4.24-10.25l9.9-9.9c5.38,5.38,8.34,12.54,8.34,20.15s-2.96,14.77-8.34,20.15Z" fill="#e8761d"/><path id="colab-s-path2" d="M48.68,49.11c-5.39,5.39-12.54,8.34-20.16,8.35-7.61,0-14.76-2.97-20.15-8.35l9.9-9.9c2.74,2.74,6.37,4.25,10.25,4.25c3.87,0,7.52-1.51,10.26-4.25l9.9,9.9Z" fill="#f5a220"/><path id="colab-s-path3" d="M18.28,39.21l-9.9,9.9C2.99,43.72,0.03,36.58,0.02,28.96c0-3.81.75-7.5,2.16-10.91c1.42-3.42,3.51-6.55,6.2-9.24l9.9,9.9c-2.74,2.74-4.26,6.38-4.26,10.25c0,1.94.38,3.82,1.1,5.55.73,1.73,1.79,3.33,3.16,4.7Z" fill="#e8761d"/><path id="colab-s-path4" d="M48.68,8.81l-9.9,9.9c-2.74-2.74-6.39-4.25-10.26-4.25s-7.51,1.51-10.25,4.25l-9.9-9.9c5.39-5.38,12.54-8.35,20.15-8.35c7.62,0,14.77,2.96,20.16,8.35Z" fill="#f5a220"/></g></g></g><clipPath id="colab-s-clippath1"><path id="colab-u-c2" d="M38.37,39.6c1.65,4.51,4.32,8.54,7.73,11.79-5.14,4.04-11.36,6.06-17.57,6.06-7.3,0-14.6-2.78-20.16-8.33C-2.74,38,-2.74,19.92,8.37,8.81c5.39-5.38,12.54-8.35,20.16-8.35c6.45,0,12.58,2.13,17.57,6.07-3.41,3.25-6.08,7.28-7.73,11.79-1.27-1.19-2.72-2.11-4.29-2.76-1.74-.72-3.62-1.1-5.55-1.1-3.88,0-7.52,1.51-10.26,4.25-5.65,5.65-5.65,14.85,0,20.51c5.53,5.52,14.42,5.65,20.1.38Z" fill="none"/></clipPath></g></g></svg>
  `;

  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