1

You can manually download the following link:

http://saved-games-alpha.s3-website-us-east-1.amazonaws.com/Jghre-0gMk@.json.gz

It's a gzip file. Unzipping it yields a file called "temp" that has the JSON data I want in it.

I need a greasemonkey script to automate this. When I run

const gzip = jQuery.get("http://saved-games-alpha.s3-website-us-east-1.amazonaws.com/Jghre-0gMk@.json.gz");

I get a successful response, but I don't know what to do with it to get the JSON.

console.log(gzip);               // the response object
console.log(gzip.responseText);  // undefined, but I can see it in the inspector as binary

I am trying to use the gunzip library here to get at the JSON, but the Firefox console just shows nothing after I call

const json_data = JXG.decompress(gzip.responseText);

How do I access the JSON data?

Important code:

const uri = "http://saved-games-alpha.s3-website-us-east-1.amazonaws.com/Jghre-0gMk@.json.gz";
console.log(uri);
const gzip = jQuery.get(uri);

console.log("gzip got");
console.log(gzip);
console.log(gzip.responseText);

console.log(JXG);

const json_data = JXG.decompress(gzip.responseText);

console.log("JSON: " + json_data); // doesn't appear in console

Console output: see https://i.stack.imgur.com/AjCmI.png

Devon Parsons
  • 1,234
  • 14
  • 23
  • Have you tried `JXG.decompress(gzip)` – akshay May 31 '15 at 18:22
  • 2
    jQuery's promise object does not have `responseText ` as a property, you need to use the promise callbacks like [then](https://api.jquery.com/deferred.then/), or [done](https://api.jquery.com/deferred.then/) to get the data – Patrick Evans May 31 '15 at 18:22
  • Also see: [Serving gzipped CSS and JavaScript from Amazon](http://stackoverflow.com/questions/5442011/serving-gzipped-css-and-javascript-from-amazon-cloudfront-via-s3) – Yogi May 31 '15 at 18:46

1 Answers1

1

You can only work with the data an ajax request returns with a call back or result of a promise. See complete here: http://api.jquery.com/jquery.ajax/

eXecute
  • 176
  • 7