Thank you for the detailed post about it on Newgrounds! Other than for in-game settings (which is what PlayerPrefs was intended for), we're actually saving our save data to an actual .dat file to the /idbfs/ in a similar fashion to what you describe in the post.
However, what we don't do and it's likely the problem is that we don't specific a hard-coded /idbfs/ directory like you do in your script, and rather do it based on the directory that the browser specifies. Given that itch.io changes the URL for the html file everytime you upload, that's likely what's causing it to get scrambled. 🤔
In some of our previous games we have included Export/Import Save file options to help mitigate the issue (and also allow for players to switch from web to desktop at any time), though because of the short time it takes to play this game, we ended up not implementing it on this one. I do plan to implement it on a future version though!
I'll have to give a better through look at your explanation and script and making a few experiments, but what you share there seems to be about right! Thank you very much for sharing it and for the explanation. Cheers! 🐳