Description
Probably because storage view/edit (v2.45).
Scenario:
I'm editing a script which stores data. While I'm editing, script is running in other tabs and storing new values. But as soon as I save the edited code, data is restored from when I opened options page, losing all the recently added values from background tabs.
Unless I did a manual change to stored value, saving a script after updating the code shouldn't overwrite storage.
Suggestion:
Create a flag like hasManuallyEditedStorage
, initially false. When a script opens for editing, add a listener to input
event (with { once: true }
) in Storage textarea. If the listener is triggered, it's because I manually changed storage by editing textarea value, so set hasManuallyEditedStorage = true
. When I click to save, the decision about if storage will be saved from textarea or not depends on hasManuallyEditedStorage
value. Unless it's true
, storage shouldn't be overwritten. After saving or clicking to edit a different script, hasManuallyEditedStorage
should back to false
and the listener should be recreated.