It's possible! The story's state is always present on the page in a hidden input, document.getElementById("pbForm").elements.SS
Its value is a base64-encoded string. If you decode it with atob()
you'll see it's got five pipe-separated groups of values:
- The story id and the current page id
- A history of every page id visited ordered from most to least recent
- Key/value pair of link id and # of times clicked
- Key/value pair of item id and # of times used
- Key/value pair of variable name and value
The first two are comma separated, but for the last three, the pairs are separated by semicolons and the key and value themselves are separated with commas.
If you're storing an integer, it's as easy as parsing that string, changing the variable, reincoding with btoa()
, and updating the input's value.
If you're trying to save noninteger values, it's more involved but doable. Internally, variable's names are not strictly enforced, so you can actually store data in a variable's name (just remember to still give it a dummy value). You could for instance include the key/value pair JS:eyJ4IjozMiwieSI6MCwieiI6MTZ9,0
and that would persist a stringified JSON object of xyz coordinates.
I don't have time to provide a bigger snippet of code right now, so I hope this information is usable! I do have a simple example of it being used here (the long variables page, not the multi-variables one).