function fetch_codechef_result(id) {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", "https://www.codechef.com/get_submission_status/" + id, true);
    xhr.send();
    xhr.onload = function(e) {
        var result = JSON.parse(xhr.response);
        if(result.result_code === 'wait') {
            setTimeout(function() {
                fetch_codechef_result(id);
            },200);
        } else {
            browser.storage.sync.get({
                sound: 'tts',
                type: 'all'
              }, function(items) {
                var sound = items.sound;
                var type = items.type;
                if(result.result_code === 'time') {
                    result.result_code = 'Time Limit Exceeded';
                }
                result.result_code = result.result_code
                    .split("_")
                    .map(word => word.charAt(0).toUpperCase() + word.slice(1))
                    .join(" ");
                notify(result.result_code,result.score,result.time,null,result.id);
              });
            listening.splice(listening.indexOf(id),1);
        }
    };
}
/**
 * Fetch the result of codechef submission
 * @param {string} id The ID of the codechef submission whose result is to be fetched
 */
Fetch the result of codechef submission
@param {string} id The ID of the codechef submission whose result is to be fetched
Fetch the result of codechef submission @param { string } id The ID of the codechef submission whose result is to be fetched
function fetch_codechef_result(id) {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", "https://www.codechef.com/get_submission_status/" + id, true);
    xhr.send();
    xhr.onload = function(e) {
        var result = JSON.parse(xhr.response);
        if(result.result_code === 'wait') {
            setTimeout(function() {
                fetch_codechef_result(id);
            },200);
        } else {
            browser.storage.sync.get({
                sound: 'tts',
                type: 'all'
              }, function(items) {
                var sound = items.sound;
                var type = items.type;
                if(result.result_code === 'time') {
                    result.result_code = 'Time Limit Exceeded';
                }
                result.result_code = result.result_code
                    .split("_")
                    .map(word => word.charAt(0).toUpperCase() + word.slice(1))
                    .join(" ");
                notify(result.result_code,result.score,result.time,null,result.id);
              });
            listening.splice(listening.indexOf(id),1);
        }
    };
}
function fetch_codechef_result ( id ) { var xhr = new XMLHttpRequest ( ) ; xhr . open ( "GET" , "https://www.codechef.com/get_submission_status/" + id , true ) ; xhr . send ( ) ; xhr . onload = function ( e ) { var result = JSON . parse ( xhr . response ) ; if ( result . result_code === 'wait' ) { setTimeout ( function ( ) { fetch_codechef_result ( id ) ; } , 200 ) ; } else { browser . storage . sync . get ( { sound : 'tts' , type : 'all' } , function ( items ) { var sound = items . sound ; var type = items . type ; if ( result . result_code === 'time' ) { result . result_code = 'Time Limit Exceeded' ; } result . result_code = result . result_code . split ( "_" ) . map ( word => word . charAt ( 0 ) . toUpperCase ( ) + word . slice ( 1 ) ) . join ( " " ) ; notify ( result . result_code , result . score , result . time , null , result . id ) ; } ) ; listening . splice ( listening . indexOf ( id ) , 1 ) ; } } ; }
Fetch the result of codechef submission
 @param {string} id The ID of the codechef submission whose result is to be fetched
Fetch the result of codechef submission @param { string } id The ID of the codechef submission whose result is to be fetched