Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Function called if AdBlock is not detected
- function adBlockNotDetected() {
- alert('AdBlock is not enabled');
- }
- // Function called if AdBlock is detected
- function adBlockDetected() {
- alert('AdBlock is enabled');
- }
- // We look at whether FlakesAdBlock already exists.
- if(typeof flakesAdBlock !== 'undefined' || typeof FlakesAdBlock !== 'undefined') {
- // If this is the case, it means that something tries to usurp are identity
- // So, considering that it is a detection
- adBlockDetected();
- } else {
- // Otherwise, you import the script FlakesAdBlock
- var importFAB = document.createElement('script');
- importFAB.onload = function() {
- // If all goes well, we configure FlakesAdBlock
- flakesAdBlock.onDetected(adBlockDetected)
- flakesAdBlock.onNotDetected(adBlockNotDetected);
- };
- importFAB.onerror = function() {
- // If the script does not load (blocked, integrity error, ...)
- // Then a detection is triggered
- adBlockDetected();
- };
- importFAB.integrity = 'sha256-xjwKUY/NgkPjZZBOtOxRYtK20GaqTwUCf7WYCJ1z69w=';
- importFAB.crossOrigin = 'anonymous';
- importFAB.src = 'https://cdnjs.cloudflare.com/ajax/libs/flakesadblock/3.2.1/flakesadblock.min.js';
- document.head.appendChild(importFAB);
- }
Add Comment
Please, Sign In to add comment