From 684a6e409c04c47f1e18154fca51da979b142a27 Mon Sep 17 00:00:00 2001 From: Adil Sadqi <42699429+AdilSadqi@users.noreply.github.com> Date: Sat, 6 Apr 2024 23:24:20 +0000 Subject: [PATCH] Update main.js.download --- index_files/main.js.download | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/index_files/main.js.download b/index_files/main.js.download index 95c1a01..25e606f 100644 --- a/index_files/main.js.download +++ b/index_files/main.js.download @@ -197,7 +197,33 @@ function commander(cmd) { addLine("Your current IP address is: " + ip, "color2", 80); }); break; - case "update": + case "speedtest": + // Function to perform speed test + function performSpeedTest(callback) { + // Using a free service to perform speed test + fetch('https://www.speedtest.net/api/js/speedtest-cdn-mini.php') + .then(response => response.json()) + .then(data => { + // Extracting download and upload speeds from the response + const downloadSpeed = data.download; + const uploadSpeed = data.upload; + callback({ download: downloadSpeed, upload: uploadSpeed }); + }) + .catch(error => callback({ error: "Unable to perform speed test" })); + } + + // Displaying the download and upload speeds + performSpeedTest(function(speeds) { + if (speeds.error) { + addLine("Error: " + speeds.error, "color2", 80); + } else { + addLine("Download Speed: " + speeds.download + " Mbps", "color2", 80); + addLine("Upload Speed: " + speeds.upload + " Mbps", "color2", 80); + } + }); + break; + + case "update": addLine("Opening Updater...", "color2", 80); setTimeout(function() { var url = '/update';