Home Entrance Wiki Search Login Register

Welcome, Guest. Please login or register.
June 10, 2023, 12:23:41 am - @974.78
Forum activity rating: Three Star Posts: 46/24hrs Unread Topics | Unread Replies | Own Posts | Own Topics | Recent Posts
News: :ozwomp: Reminder: Forum messages stay readable for years! Keep yours high quality! :ozwomp:

+  MelonLand Forum
|-+  World Wild Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ Help & Tutorials
| | | |-+  HELP: AdBlock detector


« previous next »
Pages: [1] Print
Author Topic: HELP: AdBlock detector  (Read 170 times)
JoacoEra
Newbie ⚓︎
*



View Profile WWW

Joined 2023!
« on: February 23, 2023, 08:47:51 pm »

Im looking for an easy script that detects most AdBlocks extension  :ok:
I want to make a joke in mi site for those who are using one hehe
« Last Edit: February 23, 2023, 08:49:58 pm by JoacoEra » Logged

:transport: ⌈Just a Burning Memory⌋ :TnT:
Melooon
Administrator
Hero Member ⚓︎
*****


So many stars!

SpaceHey: Friend Me!
StatusCafe: melon
iMood: Melonking
Itch.io: My Games

View Profile WWW

spring 2023!Squirtle!!!!MIDI WarriorMIDI Warrior1234 Posts!OzspeckCool Dude AwardRising Star of the Web AwardMessage BuddyPocket Icelogist!OG! Joined 2021!The Smallest Ozwomp Known To ManBug!
« Reply #1 on: February 23, 2023, 08:55:35 pm »

I have not tested this myself, but generally ad blockers try to block any elements on the page that are called "ad", its a lot more simple than you'd expect! So all you need to do is put a div on the page called like "ad" and then check to see if its been deleted or not - I found this script!

Code
// Create a fake ad element
var fakeAd = document.createElement('div');
fakeAd.innerHTML = ' ';
fakeAd.className = 'adsbox';
document.body.appendChild(fakeAd);

// Check if the element is hidden
function detectAdblock() {
  if (fakeAd.offsetHeight === 0) {
    // Adblock detected
    alert('Please disable your adblocker!');
  } else {
    // No adblock detected
    alert('Thank you for not using an adblocker!');
  }
}

// Run the function after page load
window.addEventListener('load', detectAdblock);

You could also do it without a script; make a div this has an inner div covering it with class="ad" then if the ad is blocked you'll see whats underneath it ^^  :grin:
Logged


everything lost will be recovered, when you drift into the arms of the undiscovered
Pages: [1] Print 
« previous next »
 

Vaguely similar topics! (1)

What helped you code html/css easy?

Started by MARIBoard ✁ ∙ Web Crafting

Replies: 8
Views: 335
Last post May 04, 2023, 03:50:27 pm
by lime360

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021, Simple Machines | Terms and Policies Forum Guide | Rules | RSS | WAP2


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery!