Last active
November 3, 2023 22:53
-
-
Save reeceatkinson/dcf33f5c150314cc82ea32e10d9d659c to your computer and use it in GitHub Desktop.
ABC_ARC-RA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function measureSpeed() { | |
fetch('https://fast.com/speedtest/').then(response => { | |
return response.text(); | |
}).then(data => { | |
const match = data.match(/speed-results-primary.*?(\d+\.\d+)/); | |
if (match) { | |
const downloadSpeed = match[1]; | |
console.log('Download speed: ' + downloadSpeed + ' Mbps'); | |
} else { | |
console.log('Speed test failed.'); | |
} | |
}).catch(error => { | |
console.log('Error: ' + error); | |
}); | |
} | |
// Run the speed test every 5 minutes (300,000 milliseconds) | |
setInterval(measureSpeed, 300000); | |
// Initial measurement | |
measureSpeed(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment