Tutorials 2.x Show adblock detected notice

xF-Mad

Administrative
Administrative
Joined
Apr 3, 2018
Likes
19
Location
Gangni
#1
adblock notice.png
In this guide, you'll learn how to show a notification to users about the detection of Adblock's Google advertising banner.
First, create a javascript file, namely advert.js and add it to the root directory of your forum.
add the following code to it:
JavaScript:
document.write ('<div id = "tester"> an advertisement </ div>');
Then open the extra.less template and paste it below.
CSS:
/ * AdBlock Detection * /
#tester {
    display: none;
}

.blockContainer {text-align: center; margin: 10px auto; clear: both; }
.noticeContainer {padding: 20px; background: # c44; color: #fff; }
.noticeContainer .head {font-size: 22px; font-weight: bold; }
.noticeContainer .foot {font-size: 16px; margin-top: 10px; }
Then go to the advertising section and select the ad in which you want to show the message when the ad is blocked.

After that, add this code below under the Google Adsense code:
CSS:
<script type = "text / javascript" src = "/ advertisement.js"> </ script>
        <script type = "text / javascript">
            if (document.getElementById ("tester")! = undefined)
                {
                    document.write ('');
                }
            else
                {
                    document.write ('<div class = "messageText ugc blockContainer"> <div class = "noticeContainer"> <div class = "head"> Ad-blocking software has been detected! </ div> <div class = "foot" > This website is run by the community, for the community ... and it needs ads in order to keep running. <br /> Please consider disabling your ad-block or <a href = "account / upgrades" style = "color : # FFF933; font-weight: bold "> becoming a premium member </ div> </ div> </ div> ');
                }
        </ script>