Use Recaptcha v1 will no longer replace the captcha in the original post form.

Also stop changing v2 -> v1 in the report form if loaded with the URL for v2.
This commit is contained in:
ccd0 2017-04-15 19:14:57 -07:00
parent daae2f0236
commit 9c953acd04
4 changed files with 14 additions and 36 deletions

View File

@ -3,7 +3,7 @@ Captcha.noscript =
init: -> init: ->
return if d.cookie.indexOf('pass_enabled=1') >= 0 return if d.cookie.indexOf('pass_enabled=1') >= 0
return if not (@isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt') return if not (@isEnabled = !!$ '#g-recaptcha, #captcha-forced-noscript')
container = $.el 'div', container = $.el 'div',
className: 'captcha-img' className: 'captcha-img'

View File

@ -8,13 +8,6 @@ Captcha.replace =
Captcha.v1.create() Captcha.v1.create()
return return
if (
(Conf[if g.VIEW is 'thread' then 'Use Recaptcha v1' else 'Use Recaptcha v1 on Index'] and location.hostname is 'boards.4chan.org') or
(Conf['Use Recaptcha v1 in Reports'] and location.hostname is 'sys.4chan.org')
) and Main.jsEnabled
$.ready Captcha.replace.v1
return
if Conf['Force Noscript Captcha'] and Main.jsEnabled if Conf['Force Noscript Captcha'] and Main.jsEnabled
$.ready Captcha.replace.noscript $.ready Captcha.replace.noscript
return return
@ -26,7 +19,7 @@ Captcha.replace =
$.onExists doc, 'iframe', Captcha.replace.iframe $.onExists doc, 'iframe', Captcha.replace.iframe
noscript: -> noscript: ->
return if not ((original = $ '#g-recaptcha, #captchaContainerAlt') and (noscript = $ 'noscript')) return if not ((original = $ '#g-recaptcha') and (noscript = $ 'noscript'))
span = $.el 'span', span = $.el 'span',
id: 'captcha-forced-noscript' id: 'captcha-forced-noscript'
$.replace noscript, span $.replace noscript, span
@ -39,17 +32,6 @@ Captcha.replace =
else else
insert() insert()
v1: ->
return unless $.id 'g-recaptcha'
Captcha.v1.replace()
if (link = $.id 'form-link')
$.on link, 'click', -> Captcha.v1.create()
else if location.hostname is 'boards.4chan.org'
form = $.id 'postForm'
form.addEventListener 'focus', (-> Captcha.v1.create()), true
else
Captcha.v1.create()
iframe: (iframe) -> iframe: (iframe) ->
if (lang = Conf['captchaLanguage'].trim()) if (lang = Conf['captchaLanguage'].trim())
src = if /[?&]hl=/.test iframe.src src = if /[?&]hl=/.test iframe.src

View File

@ -3,7 +3,7 @@ Captcha.v1 =
init: -> init: ->
return if d.cookie.indexOf('pass_enabled=1') >= 0 return if d.cookie.indexOf('pass_enabled=1') >= 0
return if not (@isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt') return if not (@isEnabled = !!$ '#g-recaptcha, #captcha-forced-noscript')
imgContainer = $.el 'div', imgContainer = $.el 'div',
className: 'captcha-img' className: 'captcha-img'
@ -31,23 +31,20 @@ Captcha.v1 =
Captcha.cache.init() Captcha.cache.init()
$.on d, 'CaptchaCount', @count.bind(@) $.on d, 'CaptchaCount', @count.bind(@)
@replace() @script = $.el 'script',
src: '//www.google.com/recaptcha/api/js/recaptcha_ajax.js'
$.add d.head, @script
container = $.el 'div',
id: 'captchaContainerAlt'
hidden: true
$.add d.body, container
@beforeSetup() @beforeSetup()
@setup() if Conf['Auto-load captcha'] @setup() if Conf['Auto-load captcha']
new MutationObserver(@afterSetup).observe $.id('captchaContainerAlt'), childList: true new MutationObserver(@afterSetup).observe container, childList: true
@afterSetup() # reCAPTCHA might have loaded before the QR. @afterSetup() # reCAPTCHA might have loaded before the QR.
replace: ->
return if @script
if not (@script = $ 'script[src="//www.google.com/recaptcha/api/js/recaptcha_ajax.js"]', d.head)
@script = $.el 'script',
src: '//www.google.com/recaptcha/api/js/recaptcha_ajax.js'
$.add d.head, @script
if old = $.id 'g-recaptcha'
container = $.el 'div',
id: 'captchaContainerAlt'
$.replace old, container
create: -> create: ->
cont = $.id 'captchaContainerAlt' cont = $.id 'captchaContainerAlt'
return if @occupied return if @occupied
@ -71,7 +68,6 @@ Captcha.v1 =
container = document.getElementById 'captchaContainerAlt' container = document.getElementById 'captchaContainerAlt'
options = options =
theme: 'clean' theme: 'clean'
tabindex: {"boards.4chan.org": 5}[location.hostname]
lang: container.dataset.lang lang: container.dataset.lang
if window.Recaptcha if window.Recaptcha
window.Recaptcha.create '<%= meta.recaptchaKey %>', container, options window.Recaptcha.create '<%= meta.recaptchaKey %>', container, options

View File

@ -3,7 +3,7 @@ Captcha.v2 =
init: -> init: ->
return if d.cookie.indexOf('pass_enabled=1') >= 0 return if d.cookie.indexOf('pass_enabled=1') >= 0
return if not (@isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt, #captcha-forced-noscript') return if not (@isEnabled = !!$ '#g-recaptcha, #captcha-forced-noscript')
if (@noscript = Conf['Force Noscript Captcha'] or not Main.jsEnabled) if (@noscript = Conf['Force Noscript Captcha'] or not Main.jsEnabled)
$.addClass QR.nodes.el, 'noscript-captcha' $.addClass QR.nodes.el, 'noscript-captcha'