delegate open and send for XMLHttpRequest by rewrite the prototype

发布时间 2023-08-03 21:32:48作者: zyip

 

 var sendProxied = window.XMLHttpRequest.prototype.send;
    window.XMLHttpRequest.prototype.send = function() {var object = {};
        let data = arguments[0]
        if (data && data.forEach) {
            data.forEach((value, key) => object[key] = value);
            var json = JSON.stringify(object);
        }
        return sendProxied.apply(this, [].slice.call(arguments));
    }

 

    var openProxied = window.XMLHttpRequest.prototype.open;
    window.XMLHttpRequest.prototype.open = function() {
        return openProxied.apply(this, [].slice.call(arguments));
    }