diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 19ef9fd69..894a16d7e 100755 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -396,7 +396,7 @@ Config = 'Label each post from a new IP with the thread\'s current IP count.' ] - 'Posting': + 'Posting and Captchas': 'Quick Reply': [ true 'All-in-one form to reply, create threads, automate dumping and more.' @@ -485,6 +485,10 @@ Config = true 'Make captcha easier to use, especially with the keyboard.' ] + 'Use Recaptcha v2 in Reports': [ + false + 'Use the image selection captcha in the report window.' + ] 'Quote Links': 'Quote Backlinks': [ diff --git a/src/Miscellaneous/Report.coffee b/src/Miscellaneous/Report.coffee index d2b5cdcff..fef68aba9 100755 --- a/src/Miscellaneous/Report.coffee +++ b/src/Miscellaneous/Report.coffee @@ -10,7 +10,9 @@ Report = ready: -> $.addStyle Report.css Report.archive() if Conf['Archive Report'] - if $.hasClass doc, 'js-enabled' + if Conf['Use Recaptcha v2 in Reports'] + Report.captchaV2() + if Conf['Use Recaptcha v2 in Reports'] and $.hasClass doc, 'js-enabled' new MutationObserver(-> Report.fit '.gc-bubbleDefault').observe d.body, childList: true attributes: true @@ -18,6 +20,19 @@ Report = else Report.fit 'body' + captchaV2: -> + return unless old = $.id 'captchaContainerAlt' + container = $.el 'div', + className: 'g-recaptcha' + container.dataset.sitekey = '<%= meta.recaptchaKey %>' + $.replace old, container + url = 'https://www.google.com/recaptcha/api.js' + if lang = Conf['captchaLanguage'].trim() + url += "?hl=#{encodeURIComponent lang}" + script = $.el 'script', + src: url + $.add d.head, script + fit: (selector) -> return unless el = $ selector, doc dy = el.getBoundingClientRect().bottom - doc.clientHeight + 8