Guest User

Untitled

a guest
Sep 19th, 2022
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(xhr) {
  2.  
  3.     var XHR = XMLHttpRequest.prototype;
  4.  
  5.     var open = XHR.open;
  6.     var send = XHR.send;
  7.     var setRequestHeader = XHR.setRequestHeader;
  8.  
  9.     XHR.open = function(method, url) {
  10.         this._method = method;
  11.         this._url = url;
  12.         this._requestHeaders = {};
  13.         this._startTime = (new Date()).toISOString();
  14.  
  15.         return open.apply(this, arguments);
  16.     };
  17.  
  18.     XHR.setRequestHeader = function(header, value) {
  19.         this._requestHeaders[header] = value;
  20.         return setRequestHeader.apply(this, arguments);
  21.     };
  22.  
  23.     XHR.send = function(postData) {
  24.  
  25.         this.addEventListener('load', function() {
  26.             var endTime = (new Date()).toISOString();
  27.  
  28.             var myUrl = this._url ? this._url.toLowerCase() : this._url;
  29.             if(myUrl) {
  30.  
  31.                 if (postData) {
  32.                     if (typeof postData === 'string') {
  33.                         try {
  34.                             // here you get the REQUEST HEADERS, in JSON format, so you can also use JSON.parse
  35.                             this._requestHeaders = postData;    
  36.                         } catch(err) {
  37.                             console.log('Request Header JSON decode failed, transfer_encoding field could be base64');
  38.                             console.log(err);
  39.                         }
  40.                     } else if (typeof postData === 'object' || typeof postData === 'array' || typeof postData === 'number' || typeof postData === 'boolean') {
  41.                             // do something if you need
  42.                     }
  43.                 }
  44.  
  45.                 // here you get the RESPONSE HEADERS
  46.                 var responseHeaders = this.getAllResponseHeaders();
  47.  
  48.                                                 console.log(this.responseType);
  49.                 if ( this.responseType != 'blob') {
  50.                     // responseText is string or null
  51.                     try {
  52.  
  53.                         // here you get RESPONSE TEXT (BODY), in JSON format, so you can use JSON.parse
  54.                         var arr = this.response;
  55.  
  56.                         // printing url, request headers, response headers, response body, to console
  57.                                                 console.log(" ");
  58.                         //console.log(this._url);
  59.                         //console.log(JSON-parse(this._requestHeaders));
  60.                         //console.log(responseHeaders);
  61.                                                 if(arr.includes("gameServerVersion")){
  62.                                                     console.log(arr);
  63.                                                     var wintext=arr.match(/&winnumber=[0-9]+/g);
  64.                                                     console.log(wintext[0]);
  65.                                                     let result = arr.match(/&winnumber=[0-9]+/)[0].substring(11, (arr.length-1));
  66.                                                     console.log(result);                    
  67.                                                 }                                              
  68.  
  69.                     } catch(err) {
  70.                         //console.log("Error in responseType try catch");
  71.                         //console.log(err);
  72.                     }
  73.                 }
  74.  
  75.             }
  76.         });
  77.  
  78.         return send.apply(this, arguments);
  79.     };
  80.  
  81. })(XMLHttpRequest);
  82.  
  83.  
Add Comment
Please, Sign In to add comment