זה אמור לעבוד:
let runCount = 0;
const interval = 1000 * 60 * 30; // 30 min
const results = [];
function runTest () {
$('.start-text')[0].click();
}
function getResults () {
const res = {};
['ping-speed', 'upload-speed', 'download-speed'].forEach((sel) => {
res[sel] = parseFloat($(`.${sel}`)[0].innerHTML)
});
results.push(res); return res;
}
function getAverage (field) {
return results.map(res => res[field]).reduce((p, c) => p + c, 0) / runCount;
}
function printStats () {
console.log(`
=========================
RUN COUNT: ${runCount}
Average:
PING: ${getAverage('ping-speed')}
DOWNLOAD: ${getAverage('download-speed')}
UPLOAD: ${getAverage('upload-speed')}
=========================
`);
}
function loop () {
if (runCount) {
getResults();
printStats();
}
runTest();
runCount++;
}
loop();
setInterval(loop, interval);
לך לאתר speedtest.net ותדביק את זה בקונסול. כל חמש דקות חצי שעה הוא יריץ מחדש את הטסט וידפיס את הממוצע העדכני.
ייתכן שאם הטאב לא בפוקוס הסקריפט יפסיק לעבוד, אני לא יודע.
בכל שלב אפשר לכתוב בקונסול את ה"פקודה" results ולקבל את רשימת התוצאות המלאה.
@מעלה-ומוריד אמר בהרצת בדיקת מהירות אינטרנט בלופ:
שאלתי ובקשתי אם יש מי שמוכן לכתוב או לשדך אותי למדריך לJS הנצרך.
אני מאמין שלא מדובר במשהו ארוך או מורכב, אני טועה?
לא יודע. תחליט בעצמך אם 43 שורות עונה להגדרה של ארוך או מורכב.










