Skip to content

most basic adblock detection api #44

@K2SO4AL2SO4324H2O

Description

@K2SO4AL2SO4324H2O
const adsEnabled = async () => {
 let ads = true;
    try {
      const url = `https://ads.google.com?=${new Date().getTime()}`;
      await fetch(url, { mode: "no-cors" });
    } catch (error) {
      if (error.message === "Failed to fetch") {
        ads = false;
      }
    }
return ads;
  };

// check 

const isAdEnabled = await adsEnabled();
console.log(isAdEnabled);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions