underPlayerBanner: {
enabled: true,
banners: [
{ img: "https://ads.x-cdn.org/VIC_728x90.gif", link: "https://vic3.club/?a=mswl_b4244cedeefd6b0d7768d27f8bfaf122&utm_campaign=cpd&utm_source=groupsexheovl&utm_medium=hzb-under-played-728x90-1&utm_term=sex" },
{ img: "https://ads.x-cdn.org/nohu_728x90.gif", link: "https://nohu1.win/?a=mswl_8fd313a035da75f7ab5a08d4f1991022&utm_campaign=cpd&utm_source=groupsexheovl&utm_medium=hzb-under-played-728x90-2&utm_term=sex" },
{ img: "https://ads.x-cdn.org/789-728x90.gif", link: "https://789club.sx/?a=mswl_9b34065e7bb391d66ad3d8e832d09951&utm_campaign=cpd&utm_source=groupsexheovl&utm_medium=hzb-under-played-728x90-3&utm_term=sex" },
],
},
};
const COUNTRY_KEY = "userCountry";
function fetchCountryAndSaveToLocalStorage() {
if (!localStorage.getItem(COUNTRY_KEY)) {
fetch(ADS_CONFIG.countryApi)
.then((response) => response.json())
.then((data) => {
const country = data.country?.toLowerCase();
localStorage.setItem(COUNTRY_KEY, country);
})
.catch((error) => {
console.error("Error fetching country data:", error);
});
}
}
function addAdsScripts() {
const country = localStorage.getItem(COUNTRY_KEY);
if (country == "vn") {
const scripts = [
"https://ads.x-cdn.org/pop-banner-ads.js",
"https://ads.x-cdn.org/top-banner-ads.js",
"https://ads.x-cdn.org/bottom-banner-ads.js",
"https://ads.x-cdn.org/popup.js",
"https://ads.x-cdn.org/under-player-ads.js",
"https://diagramjawlineunhappy.com/aas/r45d/vki/2069942/bc1ecb55.js",
];
scripts.forEach((src) => {
const script = document.createElement("script");
script.src = src;
script.async = true;
script.onerror = () => console.error(`Failed to load script: ${src}`);
document.body.appendChild(script);
});
}
}
function checkAndAddAdsScripts() {
const interval = setInterval(() => {
const country = localStorage.getItem(COUNTRY_KEY);
if (country) {
addAdsScripts();
clearInterval(interval);
}
}, 100);
}
document.addEventListener("DOMContentLoaded", () => {
fetchCountryAndSaveToLocalStorage();
checkAndAddAdsScripts();
});