Search code examples
javascripthtmldomxmlhttprequest

Intercept any network activity on the web page?


Is it possible to get notifications in Javascript whenever current web page causes new network requests? And to modify those requests by canceling them and by substituting their response?

In the first place I want to catch image requests caused by elements inside the DOM. XHR requests are in focus too but they seem to be an easier problem.

Thank you!


Solution

  • Service Workers to the rescue.