Witam, robię swoją stronę i znalazłem takiego adBlocker. Chciałbym zapytać o jego skuteczność i ewentualnie jak zrobić żeby podczas wyłączonego adblocka nie pojawiało się okienko tylko od razu puszczało na stronę.
js
setTimeout(() => {
var adblockEnabled = false;
document.body.innerHTML +='<div class="adsbygoogle" id="ad-detector"> </div>';
var adElement = document.getElementById("ad-detector");
var adElementStyle = getComputedStyle(adElement, null);
if(adElementStyle.display === "none"){
document.getElementsByClassName("detect")[0].innerHTML = "Adblock detected!";
document.getElementsByClassName("detect")[0].classList.add("ab");
document.getElementsByClassName("ad-p")[0].innerHTML = "Our website is made possible by displaying online advertisements to our visitors.Please consider supporting us by disabling your ad blocker on our website.";
}
else{
document.getElementsByClassName("detect")[0].innerHTML = "Adblock disabled! :)";
document.getElementsByClassName("detect")[0].classList.add("no-ab");
document.getElementsByClassName("ad-p")[0].innerHTML = "Thank you for disabling ad blocker :)";
}
}, 2000);
html
<div class="wrapper">
<img src="../img/adBlock.png">
<p class="detect">Detecting...</p>
<p class="ad-p">Please wait!</p>
</div>
css
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap");
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #1da1f2;
font-family: "Poppins", sans-serif;
}
.wrapper{
background: #fff;
max-width: 400px;
width: 100%;
border-radius: 15px;
padding: 25px;
box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.1);
}
img{
width: 120px;
margin: 18px 30%;
}
.detect{
background: #1da1f2;
color: #fff;
padding: 8px 15px;
font-weight: 600;
font-size: 22px;
text-align: center;
cursor: pointer;
}
.ad-p{
margin-top: 20px;
text-align: center;
}
.detect.ab{
background: red;
}
.detect.no-ab{
background: #1da1f2;
}