Ads help developers keep their projects running.
AdShield detects whether a visitor is running an ad blocker using three independent methods, then shows an on-brand warning modal when it finds one — no server, no third-party dependencies.
<script src="adshield.js"></script>
Every behavior lives inside a single file: appearance, copy, strictness, and detection sensitivity.
When an ad blocker is detected, a centered window opens over a blurred backdrop. It can be either impossible to dismiss (strict) or dismissible, depending on your configuration.
The THEME array lets you map background, button, and text colors to your brand identity in minutes.
Every title, description, and button label lives in the TEXTS array, so you can rewrite the tone and language to fit your brand.
Every time the modal opens, all of its elements are built with a fresh, unique ID — so ad blocker filter lists that rely on static CSS/JS selectors can't target it.
Combines bait elements, ad script loading, and ad pixel loading into a scoring system that reduces false positives.
No build step, no package manager, no server-side setup. Add the file, and it runs automatically once the page loads.
AdShield runs three independent checks in the browser. Each check casts its own vote, and at least two of them need to come back "blocked" before AdShield is confident an ad blocker is present.
Small elements hidden off-screen are added to the page with class names commonly targeted by ad blocker filter lists, such as adsbox, adsbygoogle, and text-ad. Their visibility is checked at set intervals (50ms, 400ms, 1s, 2s). If more than half of them end up hidden, this check votes "blocked".
Known ad network script files (e.g. adsbygoogle.js, gpt.js) are loaded into the page. If a script fails to load or times out (2.5 seconds by default), this check votes "blocked".
Known tracking/ad pixel URLs are requested through an <img> tag. If loading fails or times out, this check votes "blocked" as well.
positiveThreshold) is 2: if at least two of the three checks vote "blocked", AdShield decides an ad blocker is active and shows the modal according to your configured mode.
No build tools or package managers required. Copy adshield.js into your project and add one script tag — that's the entire setup.
Edit the THEME, TEXTS, and CONFIG sections at the top of adshield.js to customize appearance and behavior.