Comment by Lerc
Storing the state between levels (just score and level number?) in local storage would do the trick. Erase the state at game over. If the page launches with a state in local storage you know a game didn't finish and can resume from the start of the most recent level
Ah. I was thinking how to actually save all previous levels, but that is not needed, just the level number is needed, you're right.