Vegetarianboy30

FAB script

Jan 23rd, 2021
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Function called if AdBlock is not detected
  2. function adBlockNotDetected() {
  3.     alert('AdBlock is not enabled');
  4. }
  5. // Function called if AdBlock is detected
  6. function adBlockDetected() {
  7.     alert('AdBlock is enabled');
  8. }
  9.  
  10. // We look at whether FlakesAdBlock already exists.
  11. if(typeof flakesAdBlock !== 'undefined' || typeof FlakesAdBlock !== 'undefined') {
  12.     // If this is the case, it means that something tries to usurp are identity
  13.     // So, considering that it is a detection
  14.     adBlockDetected();
  15. } else {
  16.     // Otherwise, you import the script FlakesAdBlock
  17.     var importFAB = document.createElement('script');
  18.     importFAB.onload = function() {
  19.         // If all goes well, we configure FlakesAdBlock
  20.         flakesAdBlock.onDetected(adBlockDetected)
  21.         flakesAdBlock.onNotDetected(adBlockNotDetected);
  22.     };
  23.     importFAB.onerror = function() {
  24.         // If the script does not load (blocked, integrity error, ...)
  25.         // Then a detection is triggered
  26.         adBlockDetected();
  27.     };
  28.     importFAB.integrity = 'sha256-xjwKUY/NgkPjZZBOtOxRYtK20GaqTwUCf7WYCJ1z69w=';
  29.     importFAB.crossOrigin = 'anonymous';
  30.     importFAB.src = 'https://cdnjs.cloudflare.com/ajax/libs/flakesadblock/3.2.1/flakesadblock.min.js';
  31.     document.head.appendChild(importFAB);
  32. }
Add Comment
Please, Sign In to add comment