only check reloading text in body > h1

main
w-e-w 2025-02-22 22:53:32 +09:00
parent f7cfa87df7
commit 7f901270da
No known key found for this signature in database
GPG Key ID: 52CFE43196F6280E
1 changed files with 6 additions and 6 deletions

View File

@ -1,7 +1,7 @@
window.addEventListener('beforeunload', (event) => { window.addEventListener('beforeunload',e=> {
if (document.body.innerHTML.includes('Reloading...')) { let h1 = document.querySelector('body > h1')
return; if (!h1 || 'Reloading...' !== h1.innerText) {
e.preventDefault();
e.returnValue = 'Are you sure you want to leave Webui?';
} }
});
event.returnValue = 'Are you sure you want to leave Webui?';
});