I have a simple music player app which stores a transient playlist. I also have a scheduled dark mode on my Samsung mobile (running Android 10). When dark mode time comes around (and also if I manually toggle dark mode), Chrome refreshes the page, summarily losing the playlist and cached songs.
Ideally it wouldn't do this. Is there any way to disable this behaviour?
What I've tried
I tried setting the window.onbeforeunload
function, which stops me from manually refreshing the page. However, when I toggle the system dark mode, this is ignored and Chrome refreshes the page automatically.
I've tested toggling dark mode on my Windows 10 desktop, and Google Chrome does not refresh the page here.