Skip to content

Commit

Permalink
add intercept.js for outputting npsso to console #119
Browse files Browse the repository at this point in the history
  • Loading branch information
Tustin committed Jan 14, 2020
1 parent b5704e0 commit f8e4c01
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions intercept.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(function(open) {
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {

this.addEventListener("readystatechange", function() {
if (this.readyState == XMLHttpRequest.DONE) {
let response = JSON.parse(this.responseText);

if (response && "npsso" in response) {
console.log('found npsso', response.npsso);
}
}
}, false);

open.call(this, method, url, async, user, pass);
};

window.onbeforeunload = function(){
return 'Are you sure you want to leave?';
};

})(XMLHttpRequest.prototype.open);

0 comments on commit f8e4c01

Please sign in to comment.