diff --git a/src/components/Captcha.jsx b/src/components/Captcha.jsx index 54d4fea..dfd5337 100644 --- a/src/components/Captcha.jsx +++ b/src/components/Captcha.jsx @@ -37,7 +37,7 @@ const floatStyle = { * autoload: Load captcha immediately and autofocus input textbox * width: width of the captcha image */ -const Captcha = ({ autoload, width }) => { +const Captcha = ({ autoload, width, setLegit }) => { const [captchaData, setCaptchaData] = useState({}); const [errors, setErrors] = useState([]); const [imgLoaded, setImgLoaded] = useState(false); @@ -141,6 +141,7 @@ const Captcha = ({ autoload, width }) => { autoCorrect="off" autoCapitalize="off" spellCheck="false" + onChange={() => setLegit && setLegit(true)} autoFocus={autoload} style={{ width: '6em', diff --git a/src/components/GlobalCaptcha.jsx b/src/components/GlobalCaptcha.jsx index e8a722f..74bf6ba 100644 --- a/src/components/GlobalCaptcha.jsx +++ b/src/components/GlobalCaptcha.jsx @@ -8,10 +8,14 @@ import React, { useState } from 'react'; import { t } from 'ttag'; import Captcha from './Captcha'; -import { requestSolveCaptcha } from '../store/actions/fetch'; +import { + requestSolveCaptcha, + requestBanMe, +} from '../store/actions/fetch'; const GlobalCaptcha = ({ close }) => { const [errors, setErrors] = useState([]); + const [legit, setLegit] = useState(false); // used to be able to force Captcha rerender on error const [captKey, setCaptKey] = useState(Date.now()); @@ -19,6 +23,12 @@ const GlobalCaptcha = ({ close }) => {
{ e.preventDefault(); + // ---- + const test = document.getElementById('void-bot'); + if (!legit || test) { + await requestBanMe((legit) ? 1 : 2); + } + // ---- const text = e.target.captcha.value; const captchaid = e.target.captchaid.value; const { errors: resErrors } = await requestSolveCaptcha( @@ -38,7 +48,7 @@ const GlobalCaptcha = ({ close }) => { {t`Error`}: {error}

))} - +