mirror of
https://github.com/CyberMind-FR/secubox-deb.git
synced 2026-06-29 09:08:32 +00:00
Compare commits
3 Commits
1a8ed97cfe
...
c46e24f820
| Author | SHA1 | Date | |
|---|---|---|---|
| c46e24f820 | |||
| 3e9f6e8461 | |||
| 4315584f79 |
|
|
@ -21,7 +21,7 @@
|
||||||
if (window.__SBX_HEALTH_BANNER__) return;
|
if (window.__SBX_HEALTH_BANNER__) return;
|
||||||
window.__SBX_HEALTH_BANNER__ = true;
|
window.__SBX_HEALTH_BANNER__ = true;
|
||||||
|
|
||||||
const VERSION = '1.4.5';
|
const VERSION = '1.4.7';
|
||||||
const VISITOR_ORIGIN_API = window.SECUBOX_VISITOR_ORIGIN_API
|
const VISITOR_ORIGIN_API = window.SECUBOX_VISITOR_ORIGIN_API
|
||||||
|| '/api/v1/metrics/visitor-origin';
|
|| '/api/v1/metrics/visitor-origin';
|
||||||
const LIVE_HOSTS_API = window.SECUBOX_LIVE_HOSTS_API
|
const LIVE_HOSTS_API = window.SECUBOX_LIVE_HOSTS_API
|
||||||
|
|
@ -926,6 +926,35 @@
|
||||||
document.body.appendChild(trigger);
|
document.body.appendChild(trigger);
|
||||||
document.body.appendChild(banner);
|
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
|
// Toggle banner on trigger click
|
||||||
trigger.addEventListener('click', () => {
|
trigger.addEventListener('click', () => {
|
||||||
const isOpen = banner.classList.toggle('expanded');
|
const isOpen = banner.classList.toggle('expanded');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user