mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-27 23:16:52 +00:00
feature:
Google Adsense
This commit is contained in:
@@ -102,6 +102,31 @@ const initTheme = (theme, changeTheme) => {
|
||||
}
|
||||
}
|
||||
|
||||
export function handleRouteChange (url) {
|
||||
console.log('路由变化', url)
|
||||
initGoogleAdsense()
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化谷歌广告
|
||||
*/
|
||||
// let activeAdsCount = 0
|
||||
function initGoogleAdsense () {
|
||||
const ads = document.getElementsByClassName('adsbygoogle').length
|
||||
// const newAdsCount = ads - activeAdsCount
|
||||
// console.log(`Start: 总广告${ads}, 已激活${activeAdsCount} 新广告${newAdsCount}`)
|
||||
const newAdsCount = ads
|
||||
if (newAdsCount > 0) {
|
||||
for (let i = 0; i <= newAdsCount; i++) {
|
||||
try {
|
||||
(adsbygoogle = window.adsbygoogle || []).push({})
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取默认主题
|
||||
* @returns {*}
|
||||
|
||||
Reference in New Issue
Block a user