mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
feat(优化文章内Google AdSense处理):
(cherry picked from commit 476687e2b9126de11f8bff107b73708c18093a8e)
This commit is contained in:
@@ -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 <></>
|
||||
|
||||
Reference in New Issue
Block a user