added visual aid when debugEnabled to see if considered as bot
This commit is contained in:
parent
0917adccba
commit
588867c98b
1 changed files with 35 additions and 20 deletions
|
|
@ -41,6 +41,15 @@ const textInputs = document.querySelectorAll('input[type="text"]')
|
||||||
const captcha = document.querySelectorAll('.captcha')
|
const captcha = document.querySelectorAll('.captcha')
|
||||||
const captchaInput = document.querySelectorAll('.captcha-input')
|
const captchaInput = document.querySelectorAll('.captcha-input')
|
||||||
const captchaVerifyButton = document.querySelectorAll('.captcha-verify')
|
const captchaVerifyButton = document.querySelectorAll('.captcha-verify')
|
||||||
|
const botBadge = document.createElement('div')
|
||||||
|
if (debugEnabled) {
|
||||||
|
botBadge.className = 'bot-badge'
|
||||||
|
document.body.appendChild(botBadge)
|
||||||
|
botBadge.setAttribute(
|
||||||
|
'style',
|
||||||
|
'position: fixed; top: 0; right: 0; z-index: 9999; background-color: red; color: white; font-weight: bold; height:20px; width:20px'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Utility variables
|
// Utility variables
|
||||||
let startTime = Date.now()
|
let startTime = Date.now()
|
||||||
|
|
@ -71,6 +80,7 @@ function setUserInteracted() {
|
||||||
lastInteractionTime = currentTime
|
lastInteractionTime = currentTime
|
||||||
userInteracted = true
|
userInteracted = true
|
||||||
interactionCount++
|
interactionCount++
|
||||||
|
checkForBotBehavior()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMouseMove(event) {
|
function handleMouseMove(event) {
|
||||||
|
|
@ -110,26 +120,31 @@ function checkForBotBehavior() {
|
||||||
honeypotInput2.value !== '' ||
|
honeypotInput2.value !== '' ||
|
||||||
verifyEmailInput.value !== ''
|
verifyEmailInput.value !== ''
|
||||||
if (debugEnabled)
|
if (debugEnabled)
|
||||||
console.log(
|
if (!botDetected) {
|
||||||
'Bot Detected: ' +
|
botBadge.style.backgroundColor = 'green'
|
||||||
botDetected +
|
} else {
|
||||||
' userInteracted:' +
|
botBadge.style.backgroundColor = 'red'
|
||||||
userInteracted +
|
}
|
||||||
' interactionCount:' +
|
console.log(
|
||||||
interactionCount +
|
'Bot Detected: ' +
|
||||||
' timeSpent:' +
|
botDetected +
|
||||||
timeSpent +
|
' userInteracted:' +
|
||||||
' isStraightLine:' +
|
userInteracted +
|
||||||
isStraightLine +
|
' interactionCount:' +
|
||||||
' mousePositions:' +
|
interactionCount +
|
||||||
mousePositions.length +
|
' timeSpent:' +
|
||||||
' honeypotInput1:' +
|
timeSpent +
|
||||||
honeypotInput1.value +
|
' isStraightLine:' +
|
||||||
' honeypotInput2:' +
|
isStraightLine +
|
||||||
honeypotInput2.value +
|
' mousePositions:' +
|
||||||
' verifyEmailInput:' +
|
mousePositions.length +
|
||||||
verifyEmailInput.value
|
' honeypotInput1:' +
|
||||||
)
|
honeypotInput1.value +
|
||||||
|
' honeypotInput2:' +
|
||||||
|
honeypotInput2.value +
|
||||||
|
' verifyEmailInput:' +
|
||||||
|
verifyEmailInput.value
|
||||||
|
)
|
||||||
}
|
}
|
||||||
function handleSubmit(e) {
|
function handleSubmit(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue