Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript== // @name IDI:Ingress Data Interceptor // @namespace @mondrian // @description Intercepts Ajax data, filters it and then sends it to our server. // @include http://www.ingress.com/intel* // @include https://www.ingress.com/intel* // @match http://www.ingress.com/* // @match https://www.ingress.com/* // @grant none // @version 0.12 // ==/UserScript== IDI_VERSION = "0.12"; IDI_URL = "https://66.194.121.12/injest/ada_data.php?v=" + IDI_VERSION; (function(send) { XMLHttpRequest.prototype.send = function(vData) { if ( typeof this.storedReq == 'undefined' || this.storedReq === null ) this.storedReq = vData; send.call(this, vData); }; })(XMLHttpRequest.prototype.send); (function(open) { console.log( "IDI: open : v" + IDI_VERSION ); XMLHttpRequest.prototype.open = function(method, url, async, user, pass) { this.addEventListener("readystatechange", function() { if(this.readyState==4 && url != IDI_URL && IsJsonString( this.response) ) { //is response a duplicate? // console.log( "IDI: (RX) " + method + " " + url ); makeCorsRequest(this.response, this.storedReq); } }, false); open.call(this, method, url, async, user, pass); }; })(XMLHttpRequest.prototype.open); function IsJsonString(str) { try { JSON.parse(str); } catch (err) { console.log( "IDI: Parse error: " + err.message ); return false; } return true; } // Create the XHR object. function createCORSRequest(method, url) { var xhr = new XMLHttpRequest(); // console.log( "IDI: createCORSRequest: " + method + "::" + url); if ("withCredentials" in xhr) { // XHR for Chrome/Firefox/Opera/Safari. xhr.open(method, url, true); } else if (typeof XDomainRequest != "undefined") { // XDomainRequest for IE. xhr = new XDomainRequest(); xhr.open(method, url); } else { // CORS not supported. xhr = null; } if ( xhr !== null ) xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); return xhr; } // Make the actual CORS request. function makeCorsRequest(resp, req) { // All HTML5 Rocks properties support CORS. var url = IDI_URL; var xhr = createCORSRequest('POST', url); // console.log( "IDI: makeCorsRequest : " + resp ); if (!xhr) { console.log( "IDI: NO CORS" ); alert('CORS not supported'); return; } // Response handlers. xhr.onload = function() { var text = xhr.responseText; console.log(text); }; xhr.onerror = function() { alert('Woops, there was an error making the request.'); }; payload = JSON.parse( resp ); if ( typeof req == 'undefined' || req === null ) request = ""; else request = JSON.parse( req ); record_data = JSON.stringify({"IDI_payload": payload, "IDI_request": request}); // console.log( "IDI: sending " + record_data ); xhr.send( record_data ); }
Advertisement
Add Comment
Please, Sign In to add comment