Intercept AJAX responses in Chrome Extension [duplicate]

╄→尐↘猪︶ㄣ 提交于 2019-12-05 13:05:50

问题


We're building a chrome extension on top of an existing system, to help with a few tasks.

It's AJAX intense and it would be far more efficient than scraping html and triggering events to intercept some of the AJAX responses.

Example: Frome chrome console, networks tab, you see the beautiful JSON:

How can a Chrome Extension get to that JSON ?

I've tried WebRequest but it appear it does't allow to do this.


回答1:


If you don't mind using jQuery, you can use the

$.ajaxComplete( function( Event event, jqXHR jqXHR, PlainObject ajaxOptions ))

method on the document.

In the callback you can grab all of the information about any of the events and log them accordingly.

http://api.jquery.com/ajaxcomplete/



来源:https://stackoverflow.com/questions/23561805/intercept-ajax-responses-in-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!