Open adriaandotcom opened 2 years ago
Other ways:
var box = document.createElement("div");
box.className = "ads AdSense adpopup adszone adslot AD300";
box.style.height = "1px";
var observer = new MutationObserver(function () {
if (document.body.contains(box)) {
console.log("It's in the DOM!");
observer.disconnect();
setTimeout(function () {
var hasAdblocker = !box.offsetHeight;
console.log({ hasAdblocker });
}, 0);
}
});
observer.observe(document.body, {
attributes: false,
childList: true,
characterData: false,
subtree: true,
});
document.body.appendChild(box);
For example like this: