From 235dc584ec536bfeffbf4d00643c503e0be30059 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Sun, 28 Sep 2025 12:54:07 +0000 Subject: [PATCH] Remove responsive ad sizes and simplify ad implementation Remove mobileWidth and mobileHeight props from AdSenseAd component, update initialization logic, and simplify ad rendering to non-responsive fixed sizes. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 45a1dcfc-f8a2-475a-a6b9-96fbb841dc27 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/60d372ff-2c10-46c7-b01b-10c3435136b0/45a1dcfc-f8a2-475a-a6b9-96fbb841dc27/Myr4JGO --- .replit | 4 ++ client/src/components/adsense-ad.tsx | 84 ++++++---------------------- client/src/pages/LivePage.tsx | 6 -- client/src/pages/VideoPage.tsx | 6 -- 4 files changed, 20 insertions(+), 80 deletions(-) diff --git a/.replit b/.replit index cd990cf..25d8e76 100644 --- a/.replit +++ b/.replit @@ -23,6 +23,10 @@ externalPort = 3001 localPort = 35637 externalPort = 3000 +[[ports]] +localPort = 41551 +externalPort = 3002 + [env] PORT = "5000" diff --git a/client/src/components/adsense-ad.tsx b/client/src/components/adsense-ad.tsx index 413d2b4..f5e92da 100644 --- a/client/src/components/adsense-ad.tsx +++ b/client/src/components/adsense-ad.tsx @@ -5,8 +5,6 @@ interface AdSenseAdProps { adFormat?: 'auto' | 'rectangle' | 'vertical' | 'horizontal'; width?: number; height?: number; - mobileWidth?: number; - mobileHeight?: number; className?: string; lazy?: boolean; } @@ -16,32 +14,22 @@ export default function AdSenseAd({ adFormat = 'auto', width, height, - mobileWidth, - mobileHeight, className = '', lazy = false }: AdSenseAdProps) { const adRef = useRef(null); useEffect(() => { - const initializeAds = () => { - const insElements = adRef.current?.querySelectorAll('ins'); - if (!insElements) return; + const initializeAd = () => { + const insElement = adRef.current?.querySelector('ins'); + if (!insElement || insElement.dataset.adsbygoogleStatus === 'done') return; - insElements.forEach((insElement) => { - if (insElement.dataset.adsbygoogleStatus === 'done') return; - - // Check if this ad is visible (not hidden by responsive classes) - const computedStyle = window.getComputedStyle(insElement); - if (computedStyle.display === 'none') return; - - try { - // @ts-ignore - (window.adsbygoogle = window.adsbygoogle || []).push({}); - } catch (error) { - console.error('AdSense initialization error:', error); - } - }); + try { + // @ts-ignore + (window.adsbygoogle = window.adsbygoogle || []).push({}); + } catch (error) { + console.error('AdSense initialization error:', error); + } }; if (lazy) { @@ -50,8 +38,7 @@ export default function AdSenseAd({ (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { - // Small delay to ensure responsive CSS has been applied - setTimeout(initializeAds, 100); + initializeAd(); observer.disconnect(); } }); @@ -65,49 +52,12 @@ export default function AdSenseAd({ return () => observer.disconnect(); } else { - // Immediate initialization with delay for responsive CSS - setTimeout(initializeAds, 100); + // Immediate initialization + initializeAd(); } }, [adSlot, lazy]); - // Responsive configuration - const hasResponsiveSizes = (width && height) || (mobileWidth && mobileHeight); - - if (hasResponsiveSizes) { - // Responsive ads with different sizes for desktop/mobile - return ( -
- {/* Desktop ad */} - - {/* Mobile ad */} - -
- ); - } - - // Standard configuration (non-responsive) + // Simple non-responsive ad configuration const isFixedSize = width && height; const adStyle: React.CSSProperties = { display: 'inline-block' @@ -117,7 +67,8 @@ export default function AdSenseAd({ adStyle.width = `${width}px`; adStyle.height = `${height}px`; } else { - adStyle.width = '100%'; + // Default banner size + adStyle.width = '728px'; adStyle.height = '90px'; } @@ -132,10 +83,7 @@ export default function AdSenseAd({ style={adStyle} data-ad-client="ca-pub-4465464714854276" data-ad-slot={adSlot} - {...(isFixedSize ? {} : { - 'data-ad-format': adFormat, - 'data-full-width-responsive': 'true' - })} + data-ad-format="auto" /> ); diff --git a/client/src/pages/LivePage.tsx b/client/src/pages/LivePage.tsx index e90dcc7..8a2034c 100644 --- a/client/src/pages/LivePage.tsx +++ b/client/src/pages/LivePage.tsx @@ -461,8 +461,6 @@ export default function LivePage() { adSlot="3047267170" width={728} height={90} - mobileWidth={300} - mobileHeight={250} className="w-full" /> @@ -476,8 +474,6 @@ export default function LivePage() { adSlot="5629279662" width={728} height={90} - mobileWidth={300} - mobileHeight={250} className="w-full" /> @@ -540,8 +536,6 @@ export default function LivePage() { adSlot="9876543210" width={728} height={90} - mobileWidth={300} - mobileHeight={250} /> diff --git a/client/src/pages/VideoPage.tsx b/client/src/pages/VideoPage.tsx index fc9ced6..ba7523b 100644 --- a/client/src/pages/VideoPage.tsx +++ b/client/src/pages/VideoPage.tsx @@ -781,8 +781,6 @@ export default function VideoPage() { adSlot="5629279662" width={728} height={90} - mobileWidth={300} - mobileHeight={250} className="w-full" /> @@ -797,8 +795,6 @@ export default function VideoPage() { adSlot="5629279662" width={728} height={90} - mobileWidth={300} - mobileHeight={250} className="w-full" /> @@ -863,8 +859,6 @@ export default function VideoPage() { adSlot="1372934919" width={728} height={90} - mobileWidth={300} - mobileHeight={250} className="w-full" />