#AdBlock Detection
One way to detect AdBlock is to create a file named advert.js, set a var inside and in another script detect if this specific variable has been created. If not the advert.js file has not been load probably by adBlock.
| window.ab = false; |
| if (!('ab' in window)) { | |
| window.ab = true; | |
| } | |
| if (window.ab == true) { | |
| console.log('AdBlock is enabled'); | |
| } else { | |
| console.log('AdBlock is disabled'); | |
| } |