覆盖帖子请求

Phe*_*non 6 javascript http xmlhttprequest http-post

我在控制台中放入了以下代码:

XMLHttpRequest.prototype.send = function(body) {
    // modifies inputted request
    newBody = JSON.parse(body);
    newBody.points = 417;

  // sends modified request
    this.realSend(JSON.stringify(newBody));
}
Run Code Online (Sandbox Code Playgroud)

它应该在每次发送请求时将积分设为 417,但是当我查看请求正文时,它仍然显示原始积分数量。有什么帮助吗?

Rus*_*mir 2

尝试在修改后添加alert()或以检查它是否确实有效。有一种方法可以默默地防止这种修改。console.log()XMLHttpRequest.prototype.send