问题
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