detectDomAdblocker property

bool detectDomAdblocker

Detect if an ad blocker is blocking ads in the DOM itself

Implementation

bool get detectDomAdblocker {
  // that's a legacy Ad Block Plus check
  //  I don't think this attribute is set anymore, but I am keeping it anyway
  if (document.body?.getAttribute('abp') != null) {
    return true;
  }

  // try to lure adblockers into a trap
  final bait = _helper.createBaitElement();
  document.body?.append(bait);
  final detected = _helper.doesElementIsBlocked(bait);
  bait.remove();

  return detected;
}