This commit is contained in:
fruworg 2023-09-02 18:16:18 +06:00
commit 248393c3b3
3 changed files with 0 additions and 134 deletions

View File

@ -1,54 +0,0 @@
// Получаем информацию о браузере и операционной системе пользователя
const userAgent = navigator.userAgent;
const browser = getBrowser(userAgent);
const os = getOperatingSystem(userAgent);
// Функция для определения браузера
function getBrowser(userAgent) {
const browsers = {
Chrome: /Chrome\/([0-9]+)/,
Firefox: /Firefox\/([0-9]+)/,
Edge: /Edg\/([0-9]+)/,
IE: /Trident\/.+rv:([0-9]+)/,
Safari: /Safari\/([0-9]+)/,
Opera: /Opera\/([0-9]+)/,
};
for (const browser in browsers) {
if (browsers[browser].test(userAgent)) {
const version = userAgent.match(browsers[browser])[1];
return `${browser} ${version}`;
}
}
return 'Unknown Browser';
}
// Функция для определения операционной системы
function getOperatingSystem(userAgent) {
const operatingSystems = {
'Windows 10': /Windows NT 10/,
'Windows 8.1': /Windows NT 6.3/,
'Windows 8': /Windows NT 6.2/,
'Windows 7': /Windows NT 6.1/,
'Windows Vista': /Windows NT 6.0/,
'Windows XP': /Windows NT 5.1/,
'Windows 2000': /Windows NT 5.0/,
'Mac OS': /Mac OS X/,
'Linux': /Linux/,
'iOS': /(iPhone|iPad|iPod)/,
'Android': /Android/,
};
for (const os in operatingSystems) {
if (operatingSystems[os].test(userAgent)) {
return os;
}
}
return 'Unknown OS';
}
// Полученные значения записываем в элемент с id="user-agentt"
const uaInfoElement = document.getElementById("user-agent");
uaInfoElement.textContent = `${browser}, ${os}`;

View File

@ -1,35 +0,0 @@
// Функция для форматирования числа (добавляет ведущий ноль, если число меньше 10)
function formatNumber(num) {
return num < 10 ? '0' + num : num;
}
// Функция для получения текущего времени и дgkgаты в поясе UTC+6
function getCurrentDateTimeUTCPlus6() {
const currentTime = new Date();
const offset = currentTime.getTimezoneOffset(); // Получаем разницу в минутах между UTC и локальным временем
const utcPlus6DateTime = new Date(currentTime.getTime() + 6 * 60 * 60 * 1000); // Добавляем 6 часов к UTC+0
return utcPlus6DateTime;
}
// Функция для обновления времени и даты на странице
function updateClock() {
const timeElement = document.getElementById('time');
if (timeElement) {
const currentDateTime = getCurrentDateTimeUTCPlus6();
const date = formatNumber(currentDateTime.getUTCDate());
const month = formatNumber(currentDateTime.getUTCMonth() + 1);
const year = currentDateTime.getUTCFullYear().toString().slice(-2); // Получаем последние две цифры года
const hours = formatNumber(currentDateTime.getUTCHours());
const minutes = formatNumber(currentDateTime.getUTCMinutes());
const seconds = formatNumber(currentDateTime.getUTCSeconds());
const dateTimeString = `${date}.${month}.${year}, ${hours}:${minutes}:${seconds}, UTC+6`;
timeElement.innerText = dateTimeString;
}
}
// Обновляем время и дату каждую секунду
setInterval(updateClock, 1000);
// Вызываем функцию для первоначального обновления времени и даты
updateClock();

View File

@ -1,45 +0,0 @@
function fetchIPDetails(ip) {
const url = `https://ipapi.co/${ip}/json`;
return fetch(url)
.then((response) => response.json())
.then((data) => {
return {
ip: data.ip,
asn: data.asn,
countryCode: data.country_code,
city: data.city,
org: data.org,
};
})
.catch((error) => {
console.error("Error fetching IP details:", error);
return null;
});
}
function updateDetailsOnPage(ipDetails) {
if (ipDetails) {
const ipElement = document.getElementById("ip");
ipElement.textContent = `${ipDetails.ip}, ${ipDetails.asn}`;
const countryElement = document.getElementById("country");
countryElement.textContent = `${ipDetails.countryCode}, ${ipDetails.city}, ${ipDetails.org}`;
}
}
function getIPAddress() {
fetch("https://api.ipify.org?format=json")
.then((response) => response.json())
.then((data) => {
const userIP = data.ip;
fetchIPDetails(userIP).then((ipDetails) => {
updateDetailsOnPage(ipDetails);
});
})
.catch((error) => {
console.error("Error fetching IP:", error);
});
}
getIPAddress();