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);