48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
(function () {
|
|
function initializeRegistrationTurnstile() {
|
|
var form = document.querySelector('[data-bot-form]');
|
|
var submitButton = document.querySelector('[data-turnstile-submit]');
|
|
var status = document.querySelector('[data-turnstile-status]');
|
|
var responseField = document.querySelector('input[name="cf-turnstile-response"]');
|
|
|
|
if (!form || !submitButton || !status || !responseField) {
|
|
return;
|
|
}
|
|
|
|
var setReadyState = function () {
|
|
var hasToken = responseField.value.trim() !== '';
|
|
|
|
submitButton.disabled = !hasToken;
|
|
status.textContent = hasToken
|
|
? 'Security verification ready.'
|
|
: 'Complete the security check before continuing.';
|
|
};
|
|
|
|
setReadyState();
|
|
|
|
var syncTokenState = window.setInterval(function () {
|
|
if (!document.body.contains(form)) {
|
|
window.clearInterval(syncTokenState);
|
|
return;
|
|
}
|
|
|
|
setReadyState();
|
|
}, 250);
|
|
|
|
form.addEventListener('submit', function (event) {
|
|
if (responseField.value.trim() !== '') {
|
|
return;
|
|
}
|
|
|
|
event.preventDefault();
|
|
setReadyState();
|
|
});
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', initializeRegistrationTurnstile, { once: true });
|
|
return;
|
|
}
|
|
|
|
initializeRegistrationTurnstile();
|
|
})(); |