This commit is contained in:
2025-05-26 17:40:22 +03:00
parent e44a6a70f2
commit 50a37f7131
5 changed files with 151 additions and 446 deletions

View File

@@ -29,30 +29,13 @@
const userAgent = document.getElementById('userAgent').value || navigator.userAgent; // Используем введенный user agent или стандартный
const url = document.getElementById('url').value || window.location.href; // Используем введенный URL или текущий
const serverTs = await fetchServerTimestamp()
const secretValue = await get_secret_value(BigInt(serverTs.timestamp), userAgent, url);
// const asd = await fetch_timestamp();
const secretValue = get_secret_value(BigInt(Math.floor(Date.now() / 1000)), userAgent, url);
document.getElementById('result').innerText = secretValue;
});
}
async function fetchServerTimestamp() {
const url = "https://api.id.hublab.ru/api/v1/server-timestamp";
try {
const response = await fetch(url);
// Проверяем, успешен ли ответ
if (!response.ok) {
throw new Error(`Ошибка HTTP: ${response.status}`);
}
// Парсим JSON из ответа
const data = await response.json();
return data;
} catch (error) {
console.error("Произошла ошибка при получении времени сервера:", error);
return null; // Возвращаем null в случае ошибки
}
}