diff --git a/TGBeta.ps1 b/TGBeta.ps1 index 458f051..e619208 100644 --- a/TGBeta.ps1 +++ b/TGBeta.ps1 @@ -865,6 +865,13 @@ function GetHtmlContent { }); } + // Intercept window close or refresh + window.addEventListener('beforeunload', (event) => { + endSession(); // Clean up on window close + // Uncomment below for a confirmation dialog + event.returnValue = "Are you sure you want to leave?"; + }); + function appendLog(message, color = "white") { const log = document.createElement('p'); log.style.color = color;