Make 'Force Noscript Captcha' work on all forms. #262

This commit is contained in:
ccd0 2015-11-19 16:39:33 -08:00
parent 24288abd58
commit 210b6bd201
4 changed files with 21 additions and 7 deletions

View File

@ -470,11 +470,6 @@ Config =
'Show notifications on successful post creation or file uploading.'
1
]
'Force Noscript Captcha': [
false
'Use the non-Javascript fallback captcha in the QR even if Javascript is enabled (Recaptcha v2 only).'
1
]
'Auto-load captcha': [
false
'Automatically load the captcha in the QR even if your post is empty.'
@ -502,6 +497,10 @@ Config =
false
'Use the image selection captcha in the report window.'
]
'Force Noscript Captcha': [
false
'Use the non-Javascript fallback captcha even if Javascript is enabled (Recaptcha v2 only).'
]
'Pass Link': [
true
'Add a 4chan Pass login link to the bottom of the page.'

View File

@ -27,7 +27,7 @@ Report =
target: '_blank'
]
if Conf['Use Recaptcha v2 in Reports'] and Main.jsEnabled
if Conf['Use Recaptcha v2 in Reports'] and not Conf['Force Noscript Captcha'] and Main.jsEnabled
new MutationObserver(->
Report.fit 'iframe[src^="https://www.google.com/recaptcha/api2/frame"]'
Report.fit 'body'

View File

@ -3,6 +3,10 @@ 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 Conf['Force Noscript Captcha'] and Main.jsEnabled
$.ready Captcha.replace.noscript
return
if location.hostname is 'sys.4chan.org' and Conf['Use Recaptcha v2 in Reports'] and Main.jsEnabled
$.ready Captcha.replace.v2
return
@ -17,6 +21,14 @@ Captcha.replace =
else
$.onExists doc, 'iframe', true, Captcha.replace.iframe
noscript: ->
return unless (original = $ '#g-recaptcha, #captchaContainerAlt') and (noscript = $ 'noscript')
span = $.el 'span',
innerHTML: noscript.textContent
Captcha.replace.iframe $('iframe', span)
$.replace noscript, span
original.hidden = true
v1: ->
return unless $.id 'g-recaptcha'
Captcha.v1.replace()

View File

@ -29,7 +29,10 @@ QR =
return if g.VIEW is 'archive'
version = if Conf['Use Recaptcha v1'] then 'v1' else 'v2'
version = if Conf['Use Recaptcha v1'] and not Conf['Force Noscript Captcha'] and Main.jsEnabled
'v1'
else
'v2'
@captcha = Captcha[version]
$.on d, '4chanXInitFinished', @initReady