j4k0xb / webcrack

Deobfuscate obfuscator.io, unminify and unpack bundled javascript
https://webcrack.netlify.app
MIT License
647 stars 73 forks source link

Allow web IDE to save and/or show warning before navigating away from page (eg. refresh) #78

Closed 0xdevalias closed 1 month ago

0xdevalias commented 1 month ago

It would be cool if the web IDE allowed us to save to browser storage, or at the very least showed a popup/confirmation if we try to navigate away from /refresh the page while working on something.

I'm not sure why my muscle memory was doing it, but I kept hitting cmd+R to try and rename variables yesterday, and lost my in-progress work like 5 times before I managed to force myself to stop pressing it.

Potentially relevant:

j4k0xb commented 1 month ago

Done, it now saves and shows a prompt for 5s when loading the site Can you try it? https://deploy-preview-79--webcrack.netlify.app/ image

0xdevalias commented 1 month ago

Done, it now saves and shows a prompt for 5s when loading the site Can you try it?

@j4k0xb That is pretty cool!

A few notes:

Also did a little code review with some thoughts/notes added there:

j4k0xb commented 1 month ago

While this offers a nice 'recovery option', my original thinking (and still likely better UX for me) would probably be to warn with a 'you have unsaved changes, are you sure you want to leave' sort of confirmation. If this would be annoying for people, maybe making it configurable would work

True, gonna add that Adding a config might not even be necessary because browsers show that option Nvm still needed, it resets after a reload image

I'll probably remove the restore alert (annoying when it appears on pretty much every site load) and think of some other place in the sidebar that can be used at any time, which should also result in better UX

0xdevalias commented 1 month ago

True, gonna add that

@j4k0xb Awesome!

I'll probably remove the restore alert and think of some other place in the sidebar that can be used at any time

@j4k0xb nods sounds good. I agree that that feels like a better UX as well.

Maybe instead of just saving the files 'as is', there could be some notion of like a 'session' or similar that they get saved into? Not sure if this is overengineering it, but was sort of thinking in terms of thinking a bit like Chrome tab history/restore/similar.

Like, a completely arbitrary off the top of my head example could be that when the web app loads, it creates a UUID for that current session, and then any files that are written to storage are keyed with that UUID (and probably a 'last updated' timestamp; perhaps for the session overall, and the file).

Then in the 'restore UI', it could show the last X sessions (sorted by timestamp); or something to that effect.

(With this, was mostly thinking that since the 'restore state' is going to persist longer than 5sec now; it might make sense to try and scope/group the 'files' a bit more 'logically'; so that a new session doesn't inadvertently wipe out the old one)

0xdevalias commented 4 weeks ago

Just had a chance to quickly test this now that #79 has landed.

Trying to refresh the page (with unsaved content):

image

Trying to navigate away from the page (with unsaved content):

image

If I do reload/navigate away, when I come back, I can attempt to restore from the 'File' -> 'Open Recent' menu:

image

image

But when I clicked on it, it didn't seem to actually restore the item at all.

image