diff --git a/src/Posting/QR.captcha.coffee b/src/Posting/QR.captcha.coffee index a99fe7bb8..8a62d8b09 100644 --- a/src/Posting/QR.captcha.coffee +++ b/src/Posting/QR.captcha.coffee @@ -60,14 +60,25 @@ QR.captcha = $.globalEval ''' (function() { - var container = document.querySelector("#qr .captcha-container"); - container.dataset.widgetID = window.grecaptcha.render(container, { - sitekey: '<%= meta.recaptchaKey %>', - theme: document.documentElement.classList.contains('tomorrow') ? 'dark' : 'light', - callback: function(response) { - window.dispatchEvent(new CustomEvent("captcha:success", {detail: response})); + function render() { + var container = document.querySelector("#qr .captcha-container"); + container.dataset.widgetID = window.grecaptcha.render(container, { + sitekey: '<%= meta.recaptchaKey %>', + theme: document.documentElement.classList.contains('tomorrow') ? 'dark' : 'light', + callback: function(response) { + window.dispatchEvent(new CustomEvent("captcha:success", {detail: response})); + } + }); + } + if (window.grecaptcha) { + render(); + } else { + var cbNative = window.onRecaptchaLoaded; + window.onRecaptchaLoaded = function() { + render(); + cbNative(); } - }); + } })(); '''