Skip to content

Instantly share code, notes, and snippets.

@ipwnponies
Last active September 27, 2020 23:18
Show Gist options
  • Save ipwnponies/88bcfd19a029a84dc1b0fdc4ae713e11 to your computer and use it in GitHub Desktop.
Save ipwnponies/88bcfd19a029a84dc1b0fdc4ae713e11 to your computer and use it in GitHub Desktop.
Speed test scraper

Usage

  1. Load up the respective websites.
  2. Run script in console.
  3. Click button to run test.
  4. Results will be printed out to the console.

Blog post

function scrap() {
var dl = document.querySelector('#speed-value').textContent
var ul = document.querySelector('#upload-value').textContent
var lat = document.querySelector('#latency-value').textContent
var latLoad= document.querySelector('#bufferbloat-value').textContent
console.log([dl, ul, lat, latLoad].join(','))
}
observer = new MutationObserver((mutationsList, observer)=> {
for (const mutation of mutationsList) {
if (mutation.attributeName === 'class' && mutation.target.classList.contains('succeeded')){
scrap();
alert('copied!');
}
}
})
observer.observe(document.querySelector('#speed-progress-indicator'), {attributes: true})
function scrap() {
var dl = document.querySelector('[data-download-status-value]').textContent
var ul = document.querySelector('[data-upload-status-value]').textContent
var lat = document.querySelector('[data-latency-status-value]').textContent
console.log([dl, ul, lat].join(','))
}
observer = new MutationObserver((mutationsList, observer)=> {
for (const mutation of mutationsList) {
if (mutation.attributeName === 'class' && mutation.target.classList.contains('result-container-speed-active')){
scrap();
alert('copied!');
}
}
})
observer.observe(document.querySelector('.result-container-speed'), {attributes: true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment