Compare commits

..

No commits in common. "c46e24f8201f004afd0df86bb7aea84d9ca52de8" and "1a8ed97cfe882fc45ce0bc0ffb43e73cef189fd4" have entirely different histories.

View File

@ -21,7 +21,7 @@
if (window.__SBX_HEALTH_BANNER__) return;
window.__SBX_HEALTH_BANNER__ = true;
const VERSION = '1.4.7';
const VERSION = '1.4.5';
const VISITOR_ORIGIN_API = window.SECUBOX_VISITOR_ORIGIN_API
|| '/api/v1/metrics/visitor-origin';
const LIVE_HOSTS_API = window.SECUBOX_LIVE_HOSTS_API
@ -926,35 +926,6 @@
document.body.appendChild(trigger);
document.body.appendChild(banner);
// ── SPA re-inject guard (#750) ─────────────────────────────────────
// SPA sites (x.com, Next.js news) rebuild <body> on hydration, wiping
// our appended nodes; the one-shot __SBX_HEALTH_BANNER__ guard then
// blocks any re-init, so the banner never returns. Re-attach the
// already-created nodes — and re-add the styles if <head> was cleared
// too — whenever they detach. The closure keeps the refs alive even
// after the DOM node is wiped, and re-appending the SAME nodes
// preserves their event listeners.
function ensureMounted() {
injectBannerStyles(); // id-guarded: no-op when the <style> is present
const body = document.body;
if (!body) return;
if (!trigger.isConnected) body.appendChild(trigger);
if (!banner.isConnected) {
body.appendChild(banner);
// Re-sync the layout-shift class: a body wiped while the banner
// was expanded loses 'health-banner-open' on the fresh body.
body.classList.toggle('health-banner-open', banner.classList.contains('expanded'));
}
}
try {
// childList on <html> catches a full <body> element swap (cheap, no subtree).
new MutationObserver(ensureMounted)
.observe(document.documentElement, { childList: true });
} catch (_) { /* MutationObserver unsupported → the interval below covers it */ }
// Fallback for body.innerHTML='' (children cleared, body element kept),
// which a childList-only observer on <html> does not see.
setInterval(ensureMounted, 1500);
// Toggle banner on trigger click
trigger.addEventListener('click', () => {
const isOpen = banner.classList.toggle('expanded');