<script>
(function () {
if (window.VPNWidgetLoaded) return;
window.VPNWidgetLoaded = true;
const suspiciousKeywords = [
'vpn', 'proxy', 'tor', 'hosting', 'vps', 'cloud', 'digitalocean',
'aws', 'amazon', 'google cloud', 'azure', 'linode', 'vultr',
'nord', 'expressvpn', 'surfshark', 'cyberghost', 'proton',
'hide.me', 'scaleway', 'server', 'data center', 'colo'
];
const highRiskCountries = ['US', 'NL', 'DE', 'CA', 'GB', 'SG', 'FR', 'CH'];
function showSimpleDialog() {
const overlay = document.createElement('div');
overlay.style.cssText = `
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
background: rgba(0, 0, 0, 0.7);
display: flex;
justify-content: center;
align-items: center;
z-index: 99999;
font-family: Arial, sans-serif;
`;
const dialog = document.createElement('div');
dialog.style.cssText = `
background: white;
padding: 30px;
border-radius: 12px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
max-width: 400px;
text-align: center;
`;
dialog.innerHTML = `
<h2 style="margin: 0 0 15px 0; color: #333;">Обнаружено использование VPN</h2>
<p style="margin: 0 0 20px 0; color: #666; line-height: 1.5;">
Для корректной работы сайта требуется отключить VPN или прокси-сервер.
Пожалуйста, отключите их и обновите страницу.
</p>
<button style="
background: #4CAF50;
color: white;
border: none;
padding: 12px 24px;
border-radius: 6px;
cursor: pointer;
font-size: 16px;
">
Обновить страницу
</button>
`;
overlay.appendChild(dialog);
document.body.appendChild(overlay);
const button = dialog.querySelector('button');
button.onclick = function() {
location.reload();
};
overlay.onclick = function(e) {
if (e.target === overlay) {
document.body.removeChild(overlay);
}
};
}
function getLocalIPs() {
return new Promise(resolve => {
const ips = [];
try {
const pc = new RTCPeerConnection({ iceServers: [] });
pc.createDataChannel('');
pc.onicecandidate = e => {
if (e.candidate) {
const ip = /([0-9]{1,3}(\.[0-9]{1,3}){3})/.exec(e.candidate.candidate);
if (ip && !ips.includes(ip[1])) ips.push(ip[1]);
} else {
pc.close();
}
};
pc.createOffer()
.then(o => pc.setLocalDescription(o))
.catch(() => {});
setTimeout(() => { pc.close(); resolve(ips); }, 500);
} catch (e) {
resolve([]);
}
});
}
async function checkForVPN() {
try {
const response = await fetch('https://ipapi.co/json/');
if (!response.ok) return;
const data = await response.json();
const { country_code, org = '' } = data;
const lowerOrg = org.toLowerCase();
const hasSuspiciousOrg = suspiciousKeywords.some(kw => lowerOrg.includes(kw));
const isHighRiskCountry = highRiskCountries.includes(country_code);
let webRTCBlocked = false;
try {
const localIPs = await getLocalIPs();
webRTCBlocked = localIPs.length === 0;
} catch (e) {
webRTCBlocked = false;
}
if (hasSuspiciousOrg || (isHighRiskCountry && webRTCBlocked)) {
showSimpleDialog();
}
} catch (error) {
console.log('Проверка VPN не сработала:', error.message);
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', checkForVPN);
} else {
checkForVPN();
}
})();
</script>