Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
Autumn in Year 5 - @194.36
Five Stars Random | Recent Posts | Guild Recents
News: :cry: Are u having fun? Guild Events: weekly zine theme 12: television

+  MelonLand Forum
|-+  Life & The Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  HELP: AdBlock detector


« previous next »
Pages: [1] Print Embed
Author Topic: HELP: AdBlock detector  (Read 1617 times)
JoacoEra
Newbie
*
View Profile WWW


⛺︎ My Room

Artifacts:
First 1000 Members!Joined 2023!
« on: Winter in Year 2 @867 » Embed

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: Winter in Year 2 @868 by JoacoEra » Logged

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


So many stars!
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: melon
iMood: Melonking
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
You're a Star!Flinstone VitaminWavy Shoulder-Length Hair with BangsBug!Top HatI got robbed by Dan Q on Melonland!
« Reply #1 on: Winter in Year 2 @872 » Embed

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

Artifact Swap: black n cyan yappin kittayalien yappin kittayHave a chillpillMove it, football head!black n orange yappin kittayRed Tulip100 coinsLurby<3eyntivemds pet fishGreen partyhatPlankMaya's Magatama
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


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
@000 Melon
Land
Editor Recent Edits Tenement Arcade Random Link Land → Forum Art Hub Chat Webring Want to Login or Join ? Web Craft Guide Graphic Catalogue Wiki Newsletters Image Stream
Passport Sites Asatte Add your site?
Zap!
Minecraft: Online
Join: craft.melonking.net