Detect ad-blockers · Issue #645 · simpleanalytics/roadmap
Sun Mar 19 2023 23:35:21 GMT+0000 (Coordinated Universal Time)
Saved by
@leninzapata
#javascript
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);
content_copyCOPY
Averiguar como hace para calcular que un elemento es acterado
https://github.com/simpleanalytics/roadmap/issues/645
Comments