From 5c0c02bcfb28b1bab1267d4d08a2eabd9151565c Mon Sep 17 00:00:00 2001 From: anime Date: Tue, 24 Dec 2024 16:39:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BC=98=E5=8C=96=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=86=85Google=20AdSense=E5=A4=84=E7=90=86):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 476687e2b9126de11f8bff107b73708c18093a8e) --- components/GoogleAdsense.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/GoogleAdsense.js b/components/GoogleAdsense.js index a27d25dc..21a60009 100644 --- a/components/GoogleAdsense.js +++ b/components/GoogleAdsense.js @@ -44,6 +44,7 @@ function getNodesWithAdsByGoogleClass(node) { function checkNodeForAds(node) { if ( node.nodeType === Node.ELEMENT_NODE && + node.tagName === 'INS' && node.classList.contains('adsbygoogle') ) { adsNodes.push(node) @@ -71,7 +72,7 @@ export const initGoogleAdsense = async ADSENSE_GOOGLE_ID => { ).then(url => { setTimeout(() => { // 页面加载完成后加载一次广告 - const ads = document.getElementsByClassName('adsbygoogle') + const ads = document.querySelectorAll('ins.adsbygoogle') if (window.adsbygoogle && ads.length > 0) { requestAd(Array.from(ads)) } @@ -206,8 +207,6 @@ const AdEmbed = () => { element?.parentNode?.replaceChild(newInsElement, element) } }) - - requestAd() }, 1000) }, []) return <>