diff --git a/src/Miscellaneous/Report.coffee b/src/Miscellaneous/Report.coffee index 2326bb3c4..7ced583f5 100755 --- a/src/Miscellaneous/Report.coffee +++ b/src/Miscellaneous/Report.coffee @@ -3,15 +3,13 @@ Report = init: -> return unless /\bmode=report\b/.test(location.search) and match = location.search.match /\bno=(\d+)/ - Captcha.replace.init() unless Conf['Use Recaptcha v2 in Reports'] + Captcha.replace.init() @postID = +match[1] $.ready @ready ready: -> $.addStyle Report.css Report.archive() if Conf['Archive Report'] - 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 @@ -20,19 +18,6 @@ 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 diff --git a/src/Posting/Captcha.replace.coffee b/src/Posting/Captcha.replace.coffee index 110fc0e01..8a6f743fa 100644 --- a/src/Posting/Captcha.replace.coffee +++ b/src/Posting/Captcha.replace.coffee @@ -3,12 +3,29 @@ Captcha.replace = return unless d.cookie.indexOf('pass_enabled=1') < 0 return if location.hostname is 'boards.4chan.org' and Conf['Hide Original Post Form'] + if location.hostname is 'sys.4chan.org' and Conf['Use Recaptcha v2 in Reports'] + $.ready Captcha.replace.v2 + return + if Conf['captchaLanguage'].trim() if location.hostname is 'boards.4chan.org' $.onExists doc, '#captchaFormPart', true, (node) -> $.onExists node, 'iframe', true, Captcha.replace.iframe else $.onExists doc, 'iframe', true, Captcha.replace.iframe + v2: -> + 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 + iframe: (el) -> return unless lang = Conf['captchaLanguage'].trim() src = if /[?&]hl=/.test el.src