• Dizzy Devil Ducky
    link
    fedilink
    English
    511 months ago

    Okay, so I’ve been thinking of doing something like this for my neocities site (whenever I have the time and drive to work on it). The biggest problem to all of this is the fact I don’t wanna use any JavaScript and don’t know if it’s even possible without JS.

    I’ve already, in the past, been experimenting on another neocities page I have access to the idea of blocking access to everyone using a chromium based or safari browser with and without JS, too. To say the least, it’s difficult for a noob like me and so far has not worked like planned. Especially since there are so many forks of chromium with different names/user-agents.

    • Justas🇱🇹
      link
      fedilink
      611 months ago

      Put it in an element with a class like “ad-banner”, it should be enough for most ad blockers to block it.

      • Dizzy Devil Ducky
        link
        fedilink
        English
        111 months ago

        I’d have to look up how to do it, but I’ll definitely have to try this to see what happens.

        • Justas🇱🇹
          link
          fedilink
          2
          edit-2
          11 months ago

          just a <div>Your ad block ad goes here</div>

          view source because Lemmy understands html.

    • kopper [they/them]
      link
      fedilink
      English
      3
      edit-2
      11 months ago

      You can try to load an image from a subdomain like ads., or from a filename like 468x80.png (see EasyList) to catch all the common ad blockers, maybe with an id of Ad-Container to catch css-based ad blockers.

      DNS based blockers that use regular expressions or wildcards will work with the subdomain approach, but most of them still rely on hardcoded list of domains which means you either need to get a throwaway (sub)domain on their lists OR serve data from an actual ad server (or just live with the occasional false positives from people who believe DNS blocking is enough [which it really isn’t if we’re being honest])

      But honestly, in this case doing it with JS should be fine since disabling JS is a quite effective ad blocker anyway. Here’s how I do it for example: https://ads.d.on-t.work/ad.min.js (and you can try it out at https://w.on-t.work)

    • @brian
      link
      211 months ago

      I mean, I’d imagine it’s trivial to do without js. Just try to load an image or similar with a name that’d be blocked into the background image for a div that covers the entire page. Should silently fail to load with a blocker, or shows your error image if they don’t.

      • Dizzy Devil Ducky
        link
        fedilink
        English
        111 months ago

        As a total HTML/CSS noob, I’ll definitely have to look up how to do this. I’ll probably end up trying it on the other site just in case I royally mess up my main site by accident. I at least have immediate backups for the other site right now, so I don’t mind experimenting with it.