This commit is contained in:
2026-03-07 23:28:18 +01:00
parent d48aaa978e
commit 766eab12e7

View File

@@ -1,4 +1,13 @@
(() => { (() => {
// Disable any beforeunload prompts on this page
window.onbeforeunload = null;
window.addEventListener(
'beforeunload',
(e) => {
e.stopImmediatePropagation();
},
{ capture: true }
);
const tabBar = document.querySelector('[data-console-tab-bar]'); const tabBar = document.querySelector('[data-console-tab-bar]');
const tabPanels = document.querySelector('[data-console-tab-panels]'); const tabPanels = document.querySelector('[data-console-tab-panels]');
if (!tabBar || !tabPanels) return; if (!tabBar || !tabPanels) return;
@@ -98,15 +107,33 @@
iframe.addEventListener('load', () => { iframe.addEventListener('load', () => {
try { try {
const clearUnload = () => { const disableBeforeUnload = (win) => {
if (!iframe.contentWindow) return; if (!win) return;
iframe.contentWindow.onbeforeunload = null; try {
if (iframe.contentWindow.document) { win.onbeforeunload = null;
iframe.contentWindow.document.onbeforeunload = null; win.addEventListener(
'beforeunload',
(e) => {
e.stopImmediatePropagation();
},
{ capture: true }
);
if (win.document) {
win.document.onbeforeunload = null;
win.document.addEventListener(
'beforeunload',
(e) => {
e.stopImmediatePropagation();
},
{ capture: true }
);
}
} catch (err) {
// ignore
} }
}; };
clearUnload(); disableBeforeUnload(iframe.contentWindow);
setInterval(clearUnload, 2000); setInterval(() => disableBeforeUnload(iframe.contentWindow), 2000);
const doc = iframe.contentWindow.document; const doc = iframe.contentWindow.document;
['keydown', 'mousedown', 'wheel', 'touchstart'].forEach((evt) => { ['keydown', 'mousedown', 'wheel', 'touchstart'].forEach((evt) => {
doc.addEventListener(evt, markActive, { passive: true }); doc.addEventListener(evt, markActive, { passive: true });