4 ms·
it's a heuristic based approach, but essentially, you ensure that your ad-script would set some sort of global variable, or a property somewhere, and your detec
by chii 4y ago
it's a heuristic based approach, but essentially, you ensure that your ad-script would set some sort of global variable, or a property somewhere, and your detection script would look for that property. If it's not set, you have a good probability that the ad was blocked.
Of course, this doesn't detect element hiding.
To do so, you'd need to setup a bunch of mutation observers https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver https://developer.mozilla.org/en-US/docs/Web/API/MutationObs... , and detect that your ad's container or div/image was removed. It's a bit annoying, but doable.
Lastly, you could try to detect the adblocking scripts as well.