import { Agent as HttpsAgent } from 'https' ; import { Agent as HttpAgent } from 'http' ; import * as request from 'request' ; import randomUseragent from 'random-useragent' ; export interface HLTVConfig { loadPage : ( url : string ) => Promise < string > ; httpAgent : HttpsAgent | HttpAgent ; } export const defaultLoadPage = ( httpAgent ) => ( url ) => new Promise < string > ( ( resolve ) => { request . get ( url , { gzip : true , agent : httpAgent , headers : { 'User-Agent' : randomUseragent . getRandom ( ( ue ) => [ '/Browsers - Windows' , '/Browsers - Linux' , '/Browsers - Mac' ] . includes ( ue . folder ) ) } } , ( err , __ , body ) => { if ( err ) { throw err ; } resolve ( body ) ; } ) ; } ) ; const defaultAgent = new HttpsAgent ( ) ; export const defaultConfig = { httpAgent : defaultAgent , loadPage : defaultLoadPage ( defaultAgent ) } ;