main.js: load captcha from callback only on pages with post forms

This commit is contained in:
Zankaria 2024-09-01 23:06:15 +02:00
parent 9b6563b816
commit 76d237bc89

View file

@ -271,7 +271,7 @@ var captcha_renderer = null;
{% if config.hcaptcha %} // If hcaptcha {% if config.hcaptcha %} // If hcaptcha
function onCaptchaLoadHcaptcha() { function onCaptchaLoadHcaptcha() {
if (captcha_renderer === null) { if (captcha_renderer === null && (active_page === 'index' || active_page === 'catalog' || active_page === 'thread')) {
let renderer = { let renderer = {
renderOn: (container) => hcaptcha.render(container, { renderOn: (container) => hcaptcha.render(container, {
sitekey: "{{ config.hcaptcha_public }}", sitekey: "{{ config.hcaptcha_public }}",
@ -310,7 +310,7 @@ window.onCaptchaLoadTurnstile_post_thread = function() {
// Should be called by the captcha API when it's ready. Ugly I know... D: // Should be called by the captcha API when it's ready. Ugly I know... D:
function onCaptchaLoadTurnstile(action) { function onCaptchaLoadTurnstile(action) {
if (captcha_renderer === null) { if (captcha_renderer === null && (active_page === 'index' || active_page === 'catalog' || active_page === 'thread')) {
let renderer = { let renderer = {
renderOn: function(container) { renderOn: function(container) {
let widgetId = turnstile.render('#' + container, { let widgetId = turnstile.render('#' + container, {