diff --git a/attached_assets/image_1772358704998.png b/attached_assets/image_1772358704998.png new file mode 100644 index 0000000..b8a8de2 Binary files /dev/null and b/attached_assets/image_1772358704998.png differ diff --git a/client/src/components/adsense.tsx b/client/src/components/adsense.tsx index 4eb9fd9..42e7bf5 100644 --- a/client/src/components/adsense.tsx +++ b/client/src/components/adsense.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef } from "react"; +import { useEffect, useRef, useState } from "react"; type AdFormat = "auto" | "fluid" | "rectangle" | "horizontal" | "vertical" | "autorelaxed"; @@ -23,6 +23,7 @@ export default function AdSense({ }: AdSenseProps) { const adRef = useRef(null); const pushed = useRef(false); + const [adLoaded, setAdLoaded] = useState(false); useEffect(() => { if (pushed.current) return; @@ -32,6 +33,18 @@ export default function AdSense({ pushed.current = true; } catch (e) { } + + const timer = setTimeout(() => { + if (adRef.current) { + const ins = adRef.current; + const filled = ins.getAttribute("data-ad-status") === "filled" || + ins.children.length > 0 || + ins.clientHeight > 0; + setAdLoaded(filled); + } + }, 3000); + + return () => clearTimeout(timer); }, []); return ( @@ -92,11 +105,13 @@ export function MultiplexAd() { export function SidebarAd() { return ( -
- +
+
+ +
); } diff --git a/client/src/pages/home.tsx b/client/src/pages/home.tsx index 8d98041..62f0a11 100644 --- a/client/src/pages/home.tsx +++ b/client/src/pages/home.tsx @@ -7,7 +7,7 @@ import { Eye, Play, Images } from "lucide-react"; import { Skeleton } from "@/components/ui/skeleton"; import Header from "@/components/header"; import Footer from "@/components/footer"; -import AdSense, { ArticleCardAd, MultiplexAd } from "@/components/adsense"; +import AdSense, { ArticleCardAd, MultiplexAd, SidebarAd } from "@/components/adsense"; import { PhotoGalleryWidget } from "@/components/photo-gallery"; import { HoroscopeWidget } from "@/components/horoscope-widget"; import { RecipeWidget } from "@/components/recipe-widget"; @@ -573,6 +573,7 @@ export default function Home() {
{popular && popular.length > 0 && } +