This commit is contained in:
Zan1456
2025-06-04 16:44:42 +02:00
parent 0e1f97eaaa
commit 3ee34b90e6

View File

@@ -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;
}