Stop a tab loading

Currently I am using window.stop(); but it is slow, some things still get processed. I would like to stop the tab before any content is loaded and start an XMLHttpRequest.

Example:

window.stop();

var req = new XMLHttpRequest();
req.open('GET', document.URL, true);
req.onprogress = function() {
	//stuff
};
req.send(null);

I was thinking I could use onBeforeRequest but since I am trying to load the same page it would just turn into an infinite loop.

  • The type of the request will be main_/sub_frame in the first case and xmlhttprequest in the second
  • Instead of catching the request, you could catch the navigation.