title: Intercept WebSocket messages
body: <p>With ajax requests it can be done with this code:</p>
  <pre><code>let oldXHROpen = window.XMLHttpRequest.prototype.open;
  window.lastXhr = '';
  window.XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
    this.addEventListener('load', function() {
      window.lastXhr = this.responseText;
    });
    return oldXHROpen.apply(this, arguments);
  };
  </code></pre>
  <p><code>lastXhr</code> variable will hold the last response.</p>
  <p>But how can this be achieved for websockets too?</p>