Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-08-31 12:15:03

VegOS
New Member
Registered: 2023-08-31
Posts: 1

Detect missing adblocker

Could somebody please make a Textpattern plugin from this:
https://github.com/stefanbohacek/detect-missing-adblocker

Thanks for any consideration.

Offline

#2 2023-11-28 07:24:39

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,599
GitHub Twitter

Re: Detect missing adblocker

Add this just before your final </body> page tag:

<div id="adTest" class="ad ads adsbox doubleclick ad-placement ad-placeholder adbadge BannerAd" style="position:fixed;bottom:0;left:0;width:100%;height:1px;"></div>
<script>
const infoTitle="AdBlocker not detected";const infoText="Consider installing a browser extention that blocks ads and other malicious scripts in your browser to protect your privacy and security.";const infoAdB="https://google.com";const infoLabel="Read more";window.addEventListener("load",(()=>setTimeout((()=>{let e=document.getElementById("adTest");null!=e?("none"==window.getComputedStyle(e).getPropertyValue("display")?console.log("ADBLOCK DETECTED"):document.getElementById("adTest").insertAdjacentHTML("afterend",'<div class="full flex-columns justify-center mt1em mb3em txt-c" style="position:absolute;z-index:5;top:0;left:auto;display:flex;flex-direction:column;justify-content:center;max-width:80%;margin:auto 10%;padding:1em;background:Field;border:3px solid lightgrey"><h1>'+infoTitle+'</h1><p style="margin-top:1em;font:normal 1em/1.5 sans-serif">'+infoText+' <a href="'+infoAdB+'" target="_blank" class="btn bg-blue">'+infoLabel+'</a></p></div>'),e.remove()):console.log("ADBLOCK DETECTED")}),2e3)));
</script>

Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB