// 강화 버전: 체류 + 스크롤 + 마우스 움직임 + 클릭 패턴 + 터치 이벤트
document.addEventListener('DOMContentLoaded', function() {
const startTime = Date.now();
let scrolled = false;
let mouseMoved = false;
let clickCount = 0;
let touchCount = 0;
// 스크롤 감지
window.addEventListener('scroll', function() {
scrolled = true;
});
// 마우스 움직임 감지
window.addEventListener('mousemove', function() {
mouseMoved = true;
});
// 클릭 감지
window.addEventListener('click', function() {
clickCount++;
});
// 터치 감지 (모바일)
window.addEventListener('touchstart', function() {
touchCount++;
});
// 5초 후 행동 체크
setTimeout(function() {
const elapsed = (Date.now() - startTime) / 1000; // 초 단위
// 부정 클릭 조건
const isBot = !scrolled !mouseMoved clickCount === 0 touchCount === 0 elapsed < 5;
if (isBot) {
console.log("🚫 부정 클릭 감지: Conversion 무효 처리");
// 서버로 무효 클릭 신고 이벤트 전송
fetch('/track_invalid_click', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
ua: navigator.userAgent,
time: Date.now(),
scrolled: scrolled,
mouseMoved: mouseMoved,
clickCount: clickCount,
touchCount: touchCount
})
});
} else {
console.log("✅ 정상 사용자, 클릭 유효 처리");
}
}, 5000); // 5초 이후 체크
});