From 7de49d32d34311441789344b823d57f59275d4b7 Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Mon, 13 May 2024 11:22:26 +0200 Subject: [PATCH] added filtering for bot known bot subject and textarea --- assets/js/bestellformular.js | 10 +++++++++- assets/js/kontaktformular.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/assets/js/bestellformular.js b/assets/js/bestellformular.js index 314539b..b7c81c8 100644 --- a/assets/js/bestellformular.js +++ b/assets/js/bestellformular.js @@ -41,6 +41,11 @@ const textInputs = document.querySelectorAll('input[type="text"]') const captcha = document.querySelectorAll('.captcha') const captchaInput = document.querySelectorAll('.captcha-input') const captchaVerifyButton = document.querySelectorAll('.captcha-verify') + +// Form fields +const subjectField = document.getElementById('subject') +const messageField = document.getElementById('description') + const botBadge = document.createElement('div') if (debugEnabled) { botBadge.className = 'bot-badge' @@ -112,6 +117,9 @@ function validateZSRNumber(form) { function checkForBotBehavior() { let timeSpent = (Date.now() - startTime) / 1000 botDetected = + subjectField.value === "I promised." || +// or if messageField Has string "Hi, this is" in it + messageField.value.startsWith("Hi, this is") || !userInteracted || interactionCount === 0 || timeSpent < interactionThreshold || @@ -176,7 +184,7 @@ function handleSubmit(e) { }) .then((data) => { submitButton.disabled = true - submitButton.innerHTML = ` + submitButton.innerHTML = ` ` setTimeout(() => { diff --git a/assets/js/kontaktformular.js b/assets/js/kontaktformular.js index 606b3bc..449ebe0 100644 --- a/assets/js/kontaktformular.js +++ b/assets/js/kontaktformular.js @@ -1,5 +1,5 @@ // Configuration and Messages -const debugEnabled = true +const debugEnabled = false const mouseDebugEnabled = false const zsrCheckEnabled = false const interactionThreshold = 15 // Time in seconds