import { useEffect } from 'react' /** * 检测广告插件 * @returns */ export default function AdBlockDetect() { useEffect(() => { // 如果检测到广告屏蔽插件 function ABDetected() { if (!document) { return } const wwadsCns = document.getElementsByClassName('wwads-cn') if (wwadsCns && wwadsCns.length > 0) { for (const wwadsCn of wwadsCns) { wwadsCn.insertAdjacentHTML('beforeend', "
为了本站的长期运营,请将我们的网站加入广告拦截器的白名单,感谢您的支持!万维广告
") } } }; // check document ready function docReady(t) { document.readyState === 'complete' || document.readyState === 'interactive' ? setTimeout(t, 1) : document.addEventListener('DOMContentLoaded', t) } // check if wwads' fire function was blocked after document is ready with 3s timeout (waiting the ad loading) docReady(function () { setTimeout(function () { if (window._AdBlockInit === undefined) { ABDetected() } }, 3000) }) }, []) return null }