L
L
lysakov2016-06-15 20:39:46
contextual advertising
lysakov, 2016-06-15 20:39:46

How to block element in adblock without class and id?

On the site moskvatv.org, you need to block the script after the div element. And I can’t imagine how to do this without a class or id identifier.

<div class="afs_ads">&nbsp;</div>
<script>
(function() {
    var message = "Please disable AdBlock / Пожалуйста отключите AdBlock";

        // Define a function for showing the message.
        // Set a timeout of 2 seconds to give adblocker
        // a chance to do its thing
        var tryMessage = function() {
            setTimeout(function() {
                if(!document.getElementsByClassName) return;
                var ads = document.getElementsByClassName('afs_ads'),
                    ad  = ads[ads.length - 1];

                if(!ad
                    || ad.innerHTML.length == 0
                    || ad.clientHeight === 0) {
                    alert(message);
                    window.location.href = 'http://www.msk-tv.com/adblock.php';
                } else {
                    ad.style.display = 'none';
                }

            }, 2000);
        }

        /* Attach a listener for page load ... then show the message */
        if(window.addEventListener) {
            window.addEventListener('load', tryMessage, false);
        } else {
            window.attachEvent('onload', tryMessage); //IE
        }
})();
</script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
123459, 2016-07-22
@lysakov

moskvatv.org#@#.afs_ads I
advise you to use ublock origin - it's faster.
https://adblockplus.org/forum/viewtopic.php?f=2&t=23249
https://adblockplus.org/forum/viewtopic.php?f=2&t=23895

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question