I found some interesting (and working) answers for how to intercept an ajax call and see all of its content with javascript.(Answer1 and Answer2, ignoring the "timer approach" in answer 2).
I have a Chrome extension that works on a third's page. The page sends and receives its own ajax requests and mostly reshapes itself based on the received data. Currently, my extension can intercept and see the data received, but but it does not interfere in any of the ajax data.
Now I wish to go one step further and change the results before the page reshapes its HTML content!
Example:
User clicks a button, the page itself sends a request and receives a response with an array containing 100 elements to be displayed in a table. The page automatically creates the html table with 100 elements. Everything without my interference.
When the data is received, I can see the 100 elements received.
Now let's say I want the page to show only "50" of those elements instead of 100. How could I change the response received by the page?
Details:
- The page sends the request, not my extension (I could change the arguments sent, but that is not the best choice, I don't want to send bad requests to the server, which I cannot see or change anyhow).
- The page itself changes its DOM after receiving the response.
- I do not want to change the DOM! I need to change the data received before the page starts changing its DOM. (The amount of data received is so huge that the page gets slower than the movement of the continents, I need to prevent the elements from being created)
- The page is highly dynamic, using one of those "bootstrap-like" frameworks and most of its DOM elements are cleared and recreated each time a response is received.