覆盖XMLHttpRequest会导致加载失败

I am trying to count the number of ajax calls. I want to do this to wait until all the ajax calls return. I have written the following code:

var xmlreqc=XMLHttpRequest;

XMLHttpRequest = function() {
    this.xhr = new xmlreqc();
    return this;
};

XMLHttpRequest.prototype.open = function (method, url, async) {
return this.xhr.open(method, url, async); //send it on
};

XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
this.xhr.setRequestHeader(header, value);
};

XMLHttpRequest.prototype.getAllResponseHeaders = function() {
console.log( this.xhr.getAllResponseHeaders()); 
return this.xhr.getAllResponseHeaders();
};

XMLHttpRequest.prototype.send = function(postBody) {
     // steal the request 
     nRemAjax++;

    // do the real transmission 
     var myXHR = this;
     this.xhr.onreadystatechange = function() {  myXHR.onreadystatechangefunction();};
     this.xhr.send(postBody);
     };

     XMLHttpRequest.prototype.onreadystatechangefunction = function()
     {      
    try { 
        this.readyState = this.xhr.readyState;
        this.responseText = this.xhr.responseText;
        console.log(this.xhr.responseText); // this line log json data though
        this.responseXML = this.xhr.responseXML;
        this.status = this.xhr.status;  
        this.statusText = this.xhr.statusText;
    }
    catch(e){
    }

    if (this.onreadystatechange)
        this.onreadystatechange();

    //do my logging
    if (this.xhr.readyState == 4)
    {       
            nRemAjax--;
             // only when done steal the response 
             consoleLog("I'm finished");
    }
    };  

I have injected above code into the browser.

This works fine for most of the Websites, except for http://demo.opencart.com/index.php?route=account/register.

For some reasons, the Region/state field is not loaded properly on page load.

What I found that the Region/Field is populated with JSON data that has been send as a response from ajax call.

Please note that I am adding this script in the head.