简体   繁体   English

Chrome扩展程序拦截对特定端点的Ajax请求以修改表单数据

[英]Chrome extension intercept ajax requests to specific endpoints to modify form data

Is it possible to modify ajax requests to a specific endpoint on a webpage? 是否可以将ajax请求修改为网页上的特定端点?

For example, all requests on wwww.example.com that go to /should_intercept will trigger a function that can modify the form data? 例如,wwww.example.com上所有转到/should_intercept请求/should_intercept将触发可修改表单数据的功能? If so, how can I intercept specific requests? 如果是这样,我如何截获特定请求?

Yes, you can do it. 是的,您可以做到。

You can create a Proxy on XMLHttpRequest and inject it as a script into the page, to override original XMLHttpRequest. 您可以在XMLHttpRequest上创建一个代理 ,并将其作为脚本注入到页面中,以覆盖原始XMLHttpRequest。 And inside your implementation of the Proxy, you will be able to handle requests as you want. 在代理的实现内,您将能够根据需要处理请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM