vartestStatus=-1,dlStatus="",ulStatus="",pingStatus="",jitterStatus="",clientIp="",dlProgress=0,ulProgress=0,pingProgress=0,testId="noID",log="";functiontlog(s){log+=Date.now()+": "+s+"\n"}functiontwarn(s){log+=Date.now()+" WARN: "+s+"\n",console.warn(s)}varsettings={test_order:"IP_D_U",time_ul:15,time_dl:15,time_ulGraceTime:3,time_dlGraceTime:1.5,count_ping:35,url_dl:"garbage.php",url_ul:"empty.php",url_ping:"empty.php",url_getIp:"getIP.php",getIp_ispInfo:!0,getIp_ispInfo_distance:"km",xhr_dlMultistream:10,xhr_ulMultistream:3,xhr_multistreamDelay:300,xhr_ignoreErrors:1,xhr_dlUseBlob:!1,xhr_ul_blob_megabytes:20,garbagePhp_chunkSize:20,enable_quirks:!0,ping_allowPerformanceApi:!0,overheadCompensationFactor:1.06,useMebibits:!1,telemetry_level:0,url_telemetry:"telemetry/telemetry.php",telemetry_extra:""},xhr=null,interval=null,test_pointer=0;functionurl_sep(url){returnurl.match(/\?/)?"&":"?"}functionclearRequests(){if(tlog("stopping pending XHRs"),xhr){for(vari=0;i<xhr.length;i++){try{xhr[i].onprogress=null,xhr[i].onload=null,xhr[i].onerror=null}catch(e){}try{xhr[i].upload.onprogress=null,xhr[i].upload.onload=null,xhr[i].upload.onerror=null}catch(e){}try{xhr[i].abort()}catch(e){}try{deletexhr[i]}catch(e){}}xhr=null}}this.addEventListener("message",function(e){varparams=e.data.split(" ");if("status"===params[0]&&postMessage(JSON.stringify({testStatus:testStatus,dlStatus:dlStatus,ulStatus:ulStatus,pingStatus:pingStatus,clientIp:clientIp,jitterStatus:jitterStatus,dlProgress:dlProgress,ulProgress:ulProgress,pingProgress:pingProgress,testId:testId})),"start"===params[0]&&-1===testStatus){testStatus=0;try{vars={};try{varss=e.data.substring(5);ss&&(s=JSON.parse(ss))}catch(e){twarn("Error parsing custom settings JSON. Please check your syntax")}for(varkeyins)void0!==settings[key]?settings[key]=s[key]:twarn("Unknown setting ignored: "+key);if(settings.enable_quirks||void0!==s.enable_quirks&&s.enable_quirks){varua=navigator.userAgent;/Firefox.(\d+\.\d+)/i.test(ua)&&void0===s.xhr_ulMultistream&&(settings.xhr_ulMultistream=1),/Edge.(\d+\.\d+)/i.test(ua)&&void0===s.xhr_dlMultistream&&(settings.xhr_dlMultistream=3),/Chrome.(\d+)/i.test(ua)&&self.fetch&&void0===s.xhr_dlMultistream&&(settings.xhr_dlMultistream=5)}/Edge.(\d+\.\d+)/i.test(ua)&&(settings.forceIE11Workaround=!0),/Chrome.(\d+)/i.test(ua)&&/Android|iPhone|iPad|iPod|Windows Phone/i.test(ua)&&(settings.xhr_ul_blob_megabytes=4),void0!==s.telemetry_level&&(settings.telemetry_level="basic"===s.telemetry_level?1:"full"===s.telemetry_level?2:0),settings.test_order=settings.test_order.toUpperCase()}catch(e){twarn("Possible error in custom test settings. Some settings may not be applied. Exception: "+e)}tlog(JSON.stringify(settings)),test_pointer=0;variRun=!1,dRun=!1,uRun=!1,pRun=!1,runNextTest=function(){if(5!=testStatus)if(test_pointer>=settings.test_order.length)0<settings.telemetry_level?sendTelemetry(function(id){testStatus=4,-1!=id&&(testId=id)}):testStatus=4;elseswitch(settings.test_order.charAt(test_pointer)){case"I":if(test_pointer++,iRun)returnvoidrunNextTest();iRun=!0,getIp(runNextTest);break;case"D":if(test_pointer++,dRun)returnvoidrunNextTest();dRun=!0,testStatus=1,dlTest(runNextTest);break;case"U":if(test_pointer++,uRun)returnvoidrunNextTest();uRun=!0,testStatus=3,ulTest(runNextTest);break;case"P":if(test_pointer++,pRun)returnvoidrunNextTest();pRun=!0,testStatus=2,pingTest(runNextTest);break;case"_":test_pointer++,setTimeout(runNextTest,1e3);break;default:test_pointer++}};runNextTest()}"abort"===params[0]&&(tlog("manually aborted"),clearRequests(),runNextTest=null,interval&&clearInterval(interval),1<settings.telemetry_level&&sendTelemetry(function(){}),testStatus=5,jitterStatus=pingStatus=ulStatus=dlStatus="")});varipCalled=!1,ispInfo="";functiongetIp(done){tlog("getIp"),ipCalled||(ipCalled=!0,(xhr=newXMLHttpRequest).onload=function(){tlog("IP: "+xhr.responseText);try{vardata=JSON.parse(xhr.responseText);clientIp=data.processedString,ispInfo=data.rawIspInfo}catch(e){clientIp=xhr.responseText,ispInfo=""}done()},xhr.onerror=function(){tlog