728x90
반응형
2025.01.24 - [개발관련] - Supabase에 대한 정보 모음 (비용)
아래 코드를 <head> </head> 사이에 넣으시면 됩니다!
<script>
class AdSenseProtection {
constructor() {
this.lastClickTime = 0;
this.clickInterval = 1000; // 1초 간격
this.maxClicks = 3; // 세션당 최대 클릭 수
this.clickCount = 0;
this.resetTime = 24 * 60 * 60 * 1000; // 24시간
this.lastResetTimestamp = Date.now();
}
isValidClick() {
const now = Date.now();
// 클릭 간격 체크
if (now - this.lastClickTime < this.clickInterval) {
return false;
}
// 세션 클릭 수 체크
if (now - this.lastResetTimestamp > this.resetTime) {
this.clickCount = 0;
this.lastResetTimestamp = now;
}
if (this.clickCount >= this.maxClicks) {
return false;
}
this.lastClickTime = now;
this.clickCount++;
return true;
}
detectBot() {
const botPatterns = ['bot', 'spider', 'crawler'];
return botPatterns.some(pattern =>
navigator.userAgent.toLowerCase().includes(pattern)
);
}
preventFraud(adElement) {
if (this.detectBot()) return false;
return this.isValidClick();
}
}
// 클릭 보호 초기화
const adProtection = new AdSenseProtection();
// 모든 광고 요소에 이벤트 리스너 추가
document.querySelectorAll('.ad-element').forEach(ad => {
ad.addEventListener('click', (e) => {
if (!adProtection.preventFraud(ad)) {
e.preventDefault();
console.warn('부정 클릭 차단됨');
}
});
});
</script>
728x90
반응형
'개발관련' 카테고리의 다른 글
AWS vs GCP vs Azure 비교 (1) | 2025.01.31 |
---|---|
AWS로 워드프레스 구축하는 방법 (0) | 2025.01.31 |
디자인시스템 구축을 위해 정의되어야 할 요소는 뭐가 있을까? (0) | 2025.01.26 |
Xcode ) "Created by XXX" 코드 작성자 설정하기, XCode에서 Author 이름을 변경하는 방법 (0) | 2025.01.25 |
Supabase에 대한 정보 모음 (비용) (0) | 2025.01.24 |
iOS 앱 빌드 안되는 버그 (0) | 2025.01.24 |
Serverless MongoDB와 Firebase Firestore의 비용 비교 (0) | 2025.01.06 |
클라우드에서 빌드 실패할 때 (0) | 2025.01.03 |