Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to edit HTML game files
/*
This will take a .save game file, decode it into its JSON form,
and then save it to game-data.json
*/
const fs = require('fs');
const LZString = require('lz-string');
if (process.argv.length === 3) {
try {
const encodedData = fs.readFileSync(process.argv[2], 'utf8');
const extractedData = LZString.decompressFromBase64(encodedData);
fs.writeFileSync('game-data.json', extractedData);
console.log('All done :)');
} catch (error) {
console.log("That didn't work...");
console.log(error);
}
} else {
console.log('usage: node decoder.js [.save file]');
}
/*
This will read the game-data.json file, encode it, and save that into mygame.save
*/
const fs = require('fs');
const LZString = require('lz-string');
try {
const contents = fs.readFileSync('game-data.json', 'utf8');
const dataToSave = LZString.compressToBase64(contents);
fs.writeFileSync('mygame.save', JSON.stringify(dataToSave));
console.log('All done :)');
} catch (error) {
console.log("That didn't work...");
console.log(error);
}
@magician11

This comment has been minimized.

Copy link
Owner Author

magician11 commented Jan 12, 2019

Some online HTML games allow you to save your game to disk. It looks impossible to edit that game file, but it's not.

Download your game file..

and then run..

node decoder.js the-company-alpha-20190109-133236.save

Now you can edit the saved game data to your heart's content. Then when you're ready to upload it again, re-encode the file by running...

node encoder.js

and upload mygame.save

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.