Home Entrance Everyone Wiki Search Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
April 18, 2024 - @948.54 (what is this?)
Forum activity rating: Four Star Posts: 62/1k.beats Unread Topics | Unread Replies | Own Posts | Own Topics | Random Topic | Recent Posts
News: :dive: Are u having fun?? :dive:

+  MelonLand Forum
|-+  World Wild Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  HELP: AdBlock detector


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



View Profile WWW

First 1000 Members!Joined 2023!
« on: February 23, 2023 @866.56 »

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 @868.03 by JoacoEra » Logged

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


So many stars!

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

View Profile WWW

First 1000 Members!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 @871.93 »

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! (3)

What helped you code html/css easy?

Started by LIABoard ✁ ∙ Web Crafting

Replies: 17
Views: 1285
Last post October 11, 2023 @152.56
by lars
Melons critiquing and helping each other

Started by urgellxBoard ✎ ∙ Art Crafting

Replies: 12
Views: 711
Last post March 30, 2024 @213.02
by e-
AI-Content Detector While Browsing?

Started by YayaBoard ☞ ∙ Life on the Web

Replies: 12
Views: 336
Last post April 10, 2024 @344.70
by Gans

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! Pixel Sea TamaNOTchi