Forum Moderators: martinibuster
<div id="ad_unit">
<ins whatever></ins>
<script>
var i, m;
var interval = setInterval(() => {
if (document.readyState === 'complete') {
clearInterval(interval);
// make sure the unit exists and isn't hidden
if (i = document.getElementById('ad_unit') &&
i.style.display !== 'none' &&
i.clientWidth > 0) {
// look at all of the nodes in <div id="ad_unit">...</div>
for (m in i.childNodes)
if (
// look at the INS tag
i.childNodes[m].nodeName == 'INS' &&
// data-adsbygoogle-status is inserted, too. I've only ever seen it say
// "done", but there might be value in double checking it
i.childNodes[m].dataset.adsbygoogleStatus === 'done' &&
// now look for the data-ad-status attribute
(adStatus = i.childNodes[m].dataset.adStatus)
)
break;
// now let's see if the ad is filled
// if the height is less than 50 or if data-ad-status is 'unfilled', it's empty
if (i.clientHeight < 50 || adStatus === 'unfilled')
// do whatever
}
}
}, 500);
</script>
<ins id="foo" data-google-query-id="bar"
data-anchor-status="displayed"
data-anchor-shown="true"></ins> <style>
#homemadeAnchor {
display: none;
position: fixed;
bottom: 0;
}
</style>
<script>
var interval = setInterval(() => {
if (document.readyState === 'complete') {
clearInterval(interval);
if (!document.querySelector('ins[data-anchor-shown="true"]'))
document.getElementById('homemadeAnchor').style.display = 'block';
}
}, 500);
<div id="homemadeAnchor"></div>