flowforfrank / webtips

https://webtips.dev
1 stars 0 forks source link

how-to-reliably-check-if-adblocker-is-enabled #2

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

How to Reliably Check if Adblocker is Enabled - Weekly Webtips

Get your weekly dose of webtips

http://localhost:1234/how-to-reliably-check-if-adblocker-is-enabled

flowforfrank commented 2 years ago

Ray Sterling • 6 months ago I recommend looking deeper into how AdBlocks work, none of these methods would work. Theres a filter that fakes the load of the script ||googlesyndication.com^$script,redirect-rule=googlesyndication_adsbygoogle.js,domain=yourdomain.com and then you set a variable ##+js(set-constant, __google_ad_urls, 1)

flowforfrank commented 2 years ago

Ray Sterling • 6 months ago I recommend looking deeper into how AdBlocks work, none of these methods would work. Theres a filter that fakes the load of the script ||googlesyndication.com^$script,redirect-rule=googlesyndication_adsbygoogle.js,domain=yourdomain.com and then you set a variable ##+js(set-constant, __google_ad_urls, 1)

Hey Ray! Thank you for your comment! I recommend using the onerror approach as that is the most reliable in my opinion. Note that the tutorial is written specifically for Google Adsense. For other ad networks, the implementation may differ. I've tested it with the Adblock and Adblock Plus extension for Chrome and Firefox. At the writing of this comment, this page also has Google Adsense enabled, I suggest checking out the example through DevTools for verifying the results.