Загрузка данных


(async () => {
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;

  try {
    const r = await fetch("/api/auth/session", { credentials: "include" });

    if (!r.ok) {
      console.log("Не удалось получить session. Проверь, что ты на chatgpt.com и вошёл в аккаунт.");
      return null;
    }

    const data = await r.json();
    const id = data?.account?.id;

    if (UUID.test(id)) {
      console.log("Account UUID:", id);
      return id;
    }

    if (!data?.user) {
      console.log("Аккаунт не авторизован или session пустая.");
      return null;
    }

    console.log("Account UUID не найден. Возможно, OpenAI изменил структуру session или account.id отсутствует.");
    return null;
  } catch (e) {
    console.log("Ошибка. Запусти команду на странице chatgpt.com.");
    return null;
  }
})();