From 9a75e889324706ede073a94a014ad1ad2573152a Mon Sep 17 00:00:00 2001 From: FOLX Bot Date: Sun, 16 Aug 2026 21:41:58 +0200 Subject: [PATCH] Zaznava praznega oglasa: steje dejanski okvir oglasa, ne rezervirana visina --- client/src/components/adsense.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/src/components/adsense.tsx b/client/src/components/adsense.tsx index 3a84fc4..dc3e6c0 100644 --- a/client/src/components/adsense.tsx +++ b/client/src/components/adsense.tsx @@ -50,15 +50,21 @@ export default function AdSense({ clearTimeout(timer); onAdStatus(filled); }; + // Visina samega ni dokaz - nekatere enote imajo rezerviran prostor. + // Napolnjen oglas ima notri okvir (iframe) z dejansko visino. + const hasFrame = () => { + const f = ins.querySelector("iframe"); + return !!f && (f as HTMLIFrameElement).clientHeight > 10; + }; const check = () => { const st = ins.getAttribute("data-ad-status") || ""; if (st === "filled") return decide(true); if (st.startsWith("unfill")) return decide(false); - if (ins.clientHeight > 10) return decide(true); + if (hasFrame()) return decide(true); }; const obs = new MutationObserver(check); - obs.observe(ins, { attributes: true, attributeFilter: ["data-ad-status", "style"] }); - const timer = setTimeout(() => decide(ins.clientHeight > 10), 6000); + obs.observe(ins, { attributes: true, childList: true, subtree: true, attributeFilter: ["data-ad-status", "style"] }); + const timer = setTimeout(() => decide(hasFrame()), 6000); check(); return () => { obs.disconnect(); clearTimeout(timer); }; }, []);