Guest User

Untitled

a guest
May 22nd, 2016
1,480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. window.stephaneDetector = {
  2. detectionResult : null,
  3. broadcasted : false,
  4. traps : ['ovAdLabel', 'broker-ad', 'advertleft', 'right-takeover-ad', 'google_afc_categorymain', 'sponsored-inmail', 'inner-advt-banner-3', 'ad--mpu', 'sidebaradbox', 'advertisement-text', 'ad_blk', 'headerAds', 'adrechts', 'isocket_ad_row', 'block-bg-advertisement-region-1', 'nbaTVPodAd', 'adBtm', 'showcaseAd', 'sideBoxM1ad', 'ad-showcase', 'box_content_ad', 'adboxes', 'single-ad-anchor', 'adsImages', 'cnnSearchSponsorBox', 'marquee-ad', 'banner_250x250', 'adheader', 'agi-adsaleslinks', 'wahAdRight', 'promo-ad', 'cb-ad-banner', 'ad-300x75', 'ad-index-main', 'ADTextSingle', 'ads_sidebar', 'leftPaneAd', 'feat_ads', 'advt_widget', 'flagads', 'sponsorshipContainer', 'advertising300x250', 'postbody_ads', 'ads486x100-1', 'adBgClick', 'article-ad-left', 'ad_338_282', 'lowerContentBannerAd', 'side_ad_1', 'serp_sponsored'],
  5. hooks : [],
  6. hook : function (cb) {
  7. if (false === this.broadcasted) {
  8. this.hooks.push(cb);
  9. } else {
  10. cb(window.stephaneDetector.detectionResult);
  11. }
  12. },
  13. init : function () {
  14. var trapClasses = [
  15. this.traps[Math.floor(Math.random() * 50)],
  16. this.traps[Math.floor(Math.random() * 50)]
  17. ];
  18. var traps = [];
  19.  
  20. for (var i = 0; i < 2; i++) {
  21. traps[i] = document.createElement('div');
  22. traps[i].innerHTML = '&nbsp;';
  23. traps[i].className = trapClasses[i];
  24.  
  25. $('html')[0].appendChild(traps[i]);
  26. }
  27.  
  28. setTimeout(function () {
  29. window.stephaneDetector.detectionResult = false;
  30.  
  31. if (traps[0].offsetHeight === 0 || traps[1].offsetHeight === 0) {
  32. window.stephaneDetector.detectionResult = true;
  33. }
  34. window.stephaneDetector.broadcastResult();
  35.  
  36. traps[0].remove();
  37. traps[1].remove();
  38. }, 100);
  39. },
  40. broadcastResult : function () {
  41. $(this.hooks).each(function (i, cb) {
  42. if (_.isFunction(cb)) {
  43. cb(window.stephaneDetector.detectionResult);
  44. }
  45. });
  46. this.broadcasted = true;
  47. }
  48. };
  49. window.stephaneDetector.init();
  50.  
  51. // launch modal
  52. $(document).ready(function ($) {
  53.  
  54. window.stephaneDetector.hook(function (isDetected) {
  55. if (isDetected) {
  56. $('body').addClass('modal-open');
  57. $('#adblock-modal').addClass('modal-show');
  58.  
  59. // This disables the modal-overlay from closing the current modal window.
  60. $('#modal-overlay').click(function () {
  61. return false;
  62. });
  63.  
  64. // Set a cookie so the modal doesn't fire again for the next 'days'
  65. $(refuseButton).on('click', function () {
  66. var days = 15;
  67.  
  68. $.cookie('refuseWhitelist', 'yes', {
  69. 'path' : '/',
  70. 'expires' : days
  71. });
  72.  
  73. //close modal
  74. $('body').removeClass('modal-open');
  75. $('#adblock-modal').removeClass('modal-show');
  76. });
  77. }
  78. });
  79. });
Advertisement
Add Comment
Please, Sign In to add comment