Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.stephaneDetector = {
- detectionResult : null,
- broadcasted : false,
- 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'],
- hooks : [],
- hook : function (cb) {
- if (false === this.broadcasted) {
- this.hooks.push(cb);
- } else {
- cb(window.stephaneDetector.detectionResult);
- }
- },
- init : function () {
- var trapClasses = [
- this.traps[Math.floor(Math.random() * 50)],
- this.traps[Math.floor(Math.random() * 50)]
- ];
- var traps = [];
- for (var i = 0; i < 2; i++) {
- traps[i] = document.createElement('div');
- traps[i].innerHTML = ' ';
- traps[i].className = trapClasses[i];
- $('html')[0].appendChild(traps[i]);
- }
- setTimeout(function () {
- window.stephaneDetector.detectionResult = false;
- if (traps[0].offsetHeight === 0 || traps[1].offsetHeight === 0) {
- window.stephaneDetector.detectionResult = true;
- }
- window.stephaneDetector.broadcastResult();
- traps[0].remove();
- traps[1].remove();
- }, 100);
- },
- broadcastResult : function () {
- $(this.hooks).each(function (i, cb) {
- if (_.isFunction(cb)) {
- cb(window.stephaneDetector.detectionResult);
- }
- });
- this.broadcasted = true;
- }
- };
- window.stephaneDetector.init();
- // launch modal
- $(document).ready(function ($) {
- window.stephaneDetector.hook(function (isDetected) {
- if (isDetected) {
- $('body').addClass('modal-open');
- $('#adblock-modal').addClass('modal-show');
- // This disables the modal-overlay from closing the current modal window.
- $('#modal-overlay').click(function () {
- return false;
- });
- // Set a cookie so the modal doesn't fire again for the next 'days'
- $(refuseButton).on('click', function () {
- var days = 15;
- $.cookie('refuseWhitelist', 'yes', {
- 'path' : '/',
- 'expires' : days
- });
- //close modal
- $('body').removeClass('modal-open');
- $('#adblock-modal').removeClass('modal-show');
- });
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment