Skip to content

Instantly share code, notes, and snippets.

@HoLyVieR
Created January 15, 2012 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save HoLyVieR/1616679 to your computer and use it in GitHub Desktop.
Save HoLyVieR/1616679 to your computer and use it in GitHub Desktop.
Gameboy-Online - Export SAV file
/**
* This will let you export SAV file from a ROM.
* NOTE : Just change the "filename" variable to name of the ROM.
*/
// Getting the data //
var filename = "ROM_NAME";
var rawData = JSON.parse(localStorage["SRAM_" + filename]) // Data is stored JSON format in localStorage //
.map(function (a) { return String.fromCharCode(a); }) // We convert each value in the array to the char value //
.join(""); // We make it into a big string which is the data of the save file //
// Creating the save file popup with the hidden iframe technique //
var tmpIframe = document.createElement("iframe");
tmpIframe.src = "data:application/force-download," + escape(rawData);
tmpIframe.style.display = "none";
document.body.appendChild(tmpIframe);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment