Implement replacement of captchas with v1 everywhere.

This commit is contained in:
ccd0 2015-06-22 23:15:39 -07:00
parent 7ea5bf79a1
commit 244d40cd93
6 changed files with 26 additions and 10 deletions

View File

@ -456,11 +456,6 @@ Config =
'Show notifications on successful post creation or file uploading.'
1
]
'Use Recaptcha v1': [
false
'Use the old text version of Recaptcha.'
1
]
'Force Noscript Captcha': [
false
'Use the non-Javascript fallback captcha in the QR even if Javascript is enabled.'
@ -485,6 +480,10 @@ Config =
true
'Make captcha easier to use, especially with the keyboard.'
]
'Use Recaptcha v1': [
false
'Use the old text version of Recaptcha.'
]
'Use Recaptcha v2 in Reports': [
false
'Use the image selection captcha in the report window.'

View File

@ -59,7 +59,7 @@ Main =
$.onExists doc, 'body', false, Main.initStyle
initFeatures: ->
if location.hostname in ['boards.4chan.org', 'sys.4chan.org']
if location.hostname in ['boards.4chan.org', 'sys.4chan.org', 'www.4chan.org']
$.globalEval 'document.documentElement.classList.add("js-enabled");'
switch location.hostname

View File

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

View File

@ -3,16 +3,33 @@ 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']
jsEnabled = $.hasClass doc, 'js-enabled'
if location.hostname is 'sys.4chan.org' and Conf['Use Recaptcha v2 in Reports'] and jsEnabled
$.ready Captcha.replace.v2
return
if Conf['Use Recaptcha v1'] and jsEnabled
$.ready Captcha.replace.v1
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
v1: ->
return unless old = $.id 'g-recaptcha'
container = $.el 'div',
id: 'captchaContainerAlt'
$.replace old, container
Captcha.v1.setupScript()
if link = $ '#togglePostFormLink > a, #form-link'
$.on link, 'click', -> $.event 'captcha:setup', null, container
else
$.event 'captcha:setup', null, container
v2: ->
return unless old = $.id 'captchaContainerAlt'
container = $.el 'div',

View File

@ -1,7 +1,7 @@
Captcha.v1 =
init: ->
return if d.cookie.indexOf('pass_enabled=1') >= 0
return unless @isEnabled = !!$.id 'g-recaptcha'
return unless @isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt'
@setupScript()
captchaContainer = $.el 'div',

View File

@ -3,7 +3,7 @@ Captcha.v2 =
init: ->
return if d.cookie.indexOf('pass_enabled=1') >= 0
return unless @isEnabled = !!$.id 'g-recaptcha'
return unless @isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt'
if @noscript = Conf['Force Noscript Captcha'] or not $.hasClass doc, 'js-enabled'
@conn = new Connection null, "#{location.protocol}//www.google.com",