Predmet:Re:detekcija adblokera na web stranici - javascript
e tako, sada mi je puno jasnije.
no ova detekcija adbloka ne radi jer su vjerojatno ugradeni adblokeri u novim browserima puno napredniji pa tako recimo u brawe browseru nemozemo detektirat blokiranje oglasa.
Nasao sam jos par primjera, a neki su u jqueri ajax i sta ja znam sta sve ne pa ih nisam ni znao staviti.
evo recimo ovo isto ne radi u brawe browseru, kaze da je adbloker iskljucen a on je ukljucen
PreuzmiIzvorni kôd (Javascript):<h5 class="bg-success" id="fab-not-enabled" style="display: none; color:Tomato;">AdBlock OFF</h5>
<h5 class="bg-danger" id="fab-enabled" style="display: none; color:Tomato;">AdBlock ON</h5>
<script>
// Function called if AdBlock is not detected
function adBlockNotDetected() {
document.querySelector('#fab-enabled').style.display = 'none';
document.querySelector('#fab-not-enabled').style.display = 'block';
}
// Function called if AdBlock is detected
function adBlockDetected() {
document.querySelector('#fab-enabled').style.display = 'block';
document.querySelector('#fab-not-enabled').style.display = 'none';
}
// We look at whether FuckAdBlock already exists.
if(typeof fuckAdBlock !== 'undefined' || typeof FuckAdBlock !== 'undefined') {
// If this is the case, it means that something tries to usurp are identity
// So, considering that it is a detection
adBlockDetected();
} else {
// Otherwise, you import the script FuckAdBlock
var importFAB = document.createElement('script');
importFAB.onload = function() {
// If all goes well, we configure FuckAdBlock
fuckAdBlock.onDetected(adBlockDetected)
fuckAdBlock.onNotDetected(adBlockNotDetected);
};
importFAB.onerror = function() {
// If the script does not load (integrity problem, ...)
// Then a detection is triggered
adBlockDetected();
};
importFAB.integrity = 'sha256-4/8cdZfUJoNm8DLRzuKwvhusQbdUqVov+6bVj9ewL7U=';
importFAB.crossOrigin = 'anonymous';
importFAB.src = 'https://cdnjs.cloudflare.com/ajax/libs/fuckadblock/3.2.1/fuckadblock.js';
document.head.appendChild(importFAB);
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>
document.querySelectorAll('pre code').forEach(function(element) {
hljs.highlightBlock(element);
});
</script>
neznam gdje bi bila tu sada greska
zivot je moja domovina.
Ovaj post je ureden
2
puta. Posljednja izmjena 17.11.2021 13:50 od strane Avko.