I've been searching for a while but all I could find was examples on how to actually make those requests...
What I'm trying to do is to check if a website is making an http request after I click a button to X site
Ex. http://test.s3.amazonaws.com/test/1.txt
I'm guessing there a way to get all the outgoing requests and then filter the list but I can't even get the requests
What I've done so far is just inserting the eventlistener to check that X button has been clicked and then is when I'd like to check for those requests.
<script language="javascript">
document.getElementById("button").addEventListener('click', buttonClicked, true);
function buttonClicked(){
-->Check requests made after button is clicked.<--
}
</script>
I made a basic script for this a while ago, basically you just wrap the built-in XMLHttpRequest
.
(function() {
'use strict';
var oldXHR, stateChangeHandler, prop;
oldXHR = window.XMLHttpRequest;
stateChangeHandler = function (evt) {
switch (this.readyState) {
case oldXHR.OPENED:
console.log('Request was made', this, evt);
break;
case oldXHR.DONE:
console.log('Request finished', this, evt);
break;
}
};
function newXHR() {
var xhr = new oldXHR();
xhr.addEventListener('readystatechange', stateChangeHandler);
return xhr;
}
// Copy original states and toString
for (prop in oldXHR)
newXHR[prop] = oldXHR[prop];
window.XMLHttpRequest = newXHR;
})();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With