mirror of
https://github.com/QwIT-Development/firka-extension.git
synced 2026-06-12 03:41:39 +02:00
captcha
This commit is contained in:
@@ -14,6 +14,10 @@ async function transformLoginPage() {
|
||||
requestToken: document.querySelector('input[name="__RequestVerificationToken"]')?.value || ''
|
||||
};
|
||||
|
||||
const recaptchaDiv = document.querySelector('.g-recaptcha');
|
||||
const recaptchaPublicKey = document.querySelector('#ReCaptchaPublicKey')?.value || '';
|
||||
const showRecaptcha = document.querySelector('#ShowReCaptcha')?.value === 'True';
|
||||
|
||||
const titleElement = document.querySelector('.page-title');
|
||||
const schoolInfo = {
|
||||
name: titleElement?.querySelector('b')?.textContent?.trim() || '',
|
||||
@@ -97,6 +101,14 @@ async function transformLoginPage() {
|
||||
|
||||
document.body.innerHTML = newHTML;
|
||||
|
||||
if (showRecaptcha && recaptchaPublicKey) {
|
||||
const recaptchaScript = document.createElement('script');
|
||||
recaptchaScript.src = 'https://www.google.com/recaptcha/api.js';
|
||||
recaptchaScript.async = true;
|
||||
recaptchaScript.defer = true;
|
||||
document.head.appendChild(recaptchaScript);
|
||||
}
|
||||
|
||||
setupEventListeners();
|
||||
|
||||
} catch (error) {
|
||||
@@ -167,6 +179,24 @@ function handleSubmit(event) {
|
||||
}
|
||||
});
|
||||
|
||||
const recaptchaContainer = form.querySelector('.g-recaptcha');
|
||||
if (recaptchaContainer && window.grecaptcha) {
|
||||
const recaptchaResponse = grecaptcha.getResponse();
|
||||
if (!recaptchaResponse) {
|
||||
const errorDiv = document.createElement('div');
|
||||
errorDiv.className = 'error-message show';
|
||||
errorDiv.textContent = 'reCAPTCHA hitelesítés szükséges!';
|
||||
|
||||
const existingError = recaptchaContainer.nextElementSibling;
|
||||
if (existingError && existingError.classList.contains('error-message')) {
|
||||
existingError.remove();
|
||||
}
|
||||
|
||||
recaptchaContainer.parentNode.insertBefore(errorDiv, recaptchaContainer.nextSibling);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user