Update main.js.download

This commit is contained in:
Adil Sadqi 2024-04-07 00:04:10 +00:00 committed by GitHub
parent 15408665a3
commit 041bbd2b4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 39 deletions

View File

@ -197,48 +197,18 @@ function commander(cmd) {
addLine("Your current IP address is: " + ip, "color2", 80);
});
break;
case "speedtest":
// Function to perform speed test using speedtest.net servers
function performSpeedTest(callback) {
// Fetching the list of speedtest.net servers
fetch('https://www.speedtest.net/speedtest-servers-static.php')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(serverList => {
// Choosing a server from the list (you can customize this logic if needed)
const server = serverList[0]; // Selecting the first server for simplicity
// Fetching speed test data from the chosen server
fetch(`https://${server.url}/speedtest/upload.php`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text();
})
.then(speedData => {
// Parsing speed test data to extract speed values
const speed = parseFloat(speedData);
callback({ speed: speed });
})
.catch(error => callback({ error: "Unable to perform speed test. " + error.message }));
})
.catch(error => callback({ error: "Unable to fetch speedtest.net servers. " + error.message }));
case "time":
// Function to get current local time and date
function getCurrentTime() {
const now = new Date();
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', timeZoneName: 'short' };
const formattedTime = now.toLocaleString('en-US', options);
addLine("Current Local Time: " + formattedTime, "color2", 80);
}
// Displaying the download speed
performSpeedTest(function(speed) {
if (speed.error) {
addLine("Error: " + speed.error, "color2", 80);
} else {
addLine("Download Speed: " + speed.speed + " Mbps", "color2", 80);
}
});
// Displaying the current local time and date
getCurrentTime();
break;
case "update":
addLine("Opening Updater...", "color2", 80);
setTimeout(function() {