Skip to content

Loading…

Ad blocker detection: An overlay modal with randomly generated ID #1553

Open
pabeln opened this Issue · 3 comments

3 participants

@pabeln

Came across something new (I think). This script changes the modal/overlay ID every 500 milliseconds. When trying to change element to display:none it doesn't work. Also when deleting the modal/overlay element it gets recreated instantly.

Pretty sneaky stuff. Check it out.
http://www.startribune.com/

var km593767256614 = false;
function sv644357256614() {
    if( ! km593767256614 ) {
      userInteraction(
        ['event4'],
        {},
        'Adblock Detected'
      );
      km593767256614 = true;
    }
        (function(window) {
    setInterval( function() {
        if( ! this.id ) {
            var randNum = Math.floor(Math.random() * 99999) + 1;
            this.id = 'm9g7' + randNum;
        }
        var el = document.getElementById(this.id);
        var style = 'position:fixed; top:0; right:0; bottom:0; left:0; background:rgba(127,127,127,.8); z-index:999999; display: block;';
        if( el ) {
            var randNum = Math.floor(Math.random() * 99999) + 1;
            this.id = 'm9g7' + randNum;
            el.id = this.id;
            if( el.style.cssText != style ) {
                el.setAttribute('style', style);
            }
        } else {
            var el = document.createElement('div');
            el.id = this.id;
            el.setAttribute('style', style);
            style = el.style.cssText;
            el.innerHTML = '<div style="position:absolute; top:50%; left:50%; width:600px; height:320px; margin-top:-160px; margin-left:-300px; background:#fff; padding:75px 0; text-align:center;"> <h3 style="font: bold 34px/1 \'Popular\',Helvetica,Arial,sans-serif;">You&rsquo;re using an ad blocker.</h3> <h4 style="font: normal 22px/1 Whitman OSF,Georgia,Times,serif; margin: 1.3em 0 0.6em;"><span style="line-height: 1;">&nbsp;T</span><span style="line-height: 1;">o continue reading, p</span>lease disable ad blocker for our site.</h4> <h4 style="font:normal 22px/1 Whitman OSF,Georgia,Times,serif; margin: .6em 0 1.4em;">Click this icon in your menu bar: <img style="display:inline; margin:0 auto; width:27px; height:16px;" src="http://stmedia.startribune.com/images/ABP_logo.png" alt="" /></h4> <img style="display:block; margin:0 auto; width:250px; height:37px;" src="/static/img/icons/icn-nav-shortnav-logo-160-25.svg" alt="" /></div>';
            var bodyNodes = window.document.body.childNodes;
            var insertAfter = Math.floor(Math.random() * bodyNodes.length);
            var insertNode = bodyNodes[insertAfter];
            window.document.body.insertBefore(el, insertNode);
        }
      } , 500 );
    })(window);
    }

Anyway to block this?

@gorhill
||www.startribune.com^$inline-script

But this will cause all inline script tags to be disabled, including the "good" ones, if any.

@thegoodthings

Something like startribune.com##body > div[style^="position:fixed"] will also work, if inline-script blocking happens to break some important thing.

@pabeln

You guys are brilliant - one23 that worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.