Add option to request captcha from captcha services when you start typing.
This commit is contained in:
parent
95c66ee153
commit
6a3f0f44bb
@ -54,6 +54,9 @@
|
|||||||
API Key: <input name="captchaServiceKey" class="field" spellcheck="false">
|
API Key: <input name="captchaServiceKey" class="field" spellcheck="false">
|
||||||
<datalist id="list-captchaServiceDomain"></datalist>
|
<datalist id="list-captchaServiceDomain"></datalist>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label><input type="checkbox" name="Prerequest Captcha"> Request captcha when you start typing. Quicker but may result some captchas expiring and being wasted.</label>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|||||||
@ -10,19 +10,39 @@ Captcha.cache =
|
|||||||
getCount: ->
|
getCount: ->
|
||||||
@captchas.length
|
@captchas.length
|
||||||
|
|
||||||
needed: ->
|
neededRaw: ->
|
||||||
not (
|
not (
|
||||||
@haveCookie() or @captchas.length or QR.req
|
@haveCookie() or @captchas.length or QR.req or @submitCB
|
||||||
) and (
|
) and (
|
||||||
QR.posts.length > 1 or Conf['Auto-load captcha'] or /^\s*[^\s>]/m.test(QR.posts[0].com or '') or QR.posts[0].file
|
QR.posts.length > 1 or Conf['Auto-load captcha'] or /^\s*[^\s>]/m.test(QR.posts[0].com or '') or QR.posts[0].file
|
||||||
) and (
|
|
||||||
@submitCB or $.event('LoadCaptcha')
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
needed: ->
|
||||||
|
@neededRaw() and $.event('LoadCaptcha')
|
||||||
|
|
||||||
|
prerequest: ->
|
||||||
|
return unless Conf['Prerequest Captcha']
|
||||||
|
# Post count temporarily off by 1 when called from QR.post.rm, QR.close, or QR.submit
|
||||||
|
$.queueTask =>
|
||||||
|
if (
|
||||||
|
!@prerequested and
|
||||||
|
@neededRaw() and
|
||||||
|
!$.event('LoadCaptcha') and
|
||||||
|
!QR.captcha.occupied() and
|
||||||
|
QR.cooldown.seconds <= 60 and
|
||||||
|
QR.selected is QR.posts[QR.posts.length - 1] and
|
||||||
|
/^\s*[^\s>]/m.test(QR.selected.com or '')
|
||||||
|
)
|
||||||
|
isReply = (QR.selected.thread isnt 'new')
|
||||||
|
if !$.event('RequestCaptcha', {isReply})
|
||||||
|
@prerequested = true
|
||||||
|
@submitCB = @save.bind(@)
|
||||||
|
|
||||||
haveCookie: ->
|
haveCookie: ->
|
||||||
/\b_ct=/.test(d.cookie) and QR.posts[0].thread isnt 'new'
|
/\b_ct=/.test(d.cookie) and QR.posts[0].thread isnt 'new'
|
||||||
|
|
||||||
getOne: ->
|
getOne: ->
|
||||||
|
delete @prerequested
|
||||||
@clear()
|
@clear()
|
||||||
if (captcha = @captchas.shift())
|
if (captcha = @captchas.shift())
|
||||||
@count()
|
@count()
|
||||||
@ -31,7 +51,8 @@ Captcha.cache =
|
|||||||
null
|
null
|
||||||
|
|
||||||
request: (isReply) ->
|
request: (isReply) ->
|
||||||
return if $.event('RequestCaptcha', {isReply})
|
if !@submitCB
|
||||||
|
return if $.event('RequestCaptcha', {isReply})
|
||||||
(cb) => @submitCB = cb
|
(cb) => @submitCB = cb
|
||||||
|
|
||||||
abort: ->
|
abort: ->
|
||||||
|
|||||||
@ -192,3 +192,6 @@ Captcha.v2 =
|
|||||||
$.global ->
|
$.global ->
|
||||||
container = document.querySelector '#qr .captcha-container'
|
container = document.querySelector '#qr .captcha-container'
|
||||||
window.grecaptcha.reset container.dataset.widgetID
|
window.grecaptcha.reset container.dataset.widgetID
|
||||||
|
|
||||||
|
occupied: ->
|
||||||
|
!!@nodes.container and !@timeouts.destroy
|
||||||
|
|||||||
@ -167,6 +167,7 @@ QR.post = class
|
|||||||
QR.characterCount()
|
QR.characterCount()
|
||||||
@nodes.span.textContent = @com
|
@nodes.span.textContent = @com
|
||||||
QR.captcha.moreNeeded()
|
QR.captcha.moreNeeded()
|
||||||
|
Captcha.cache.prerequest()
|
||||||
|
|
||||||
@rmErrored: (e) ->
|
@rmErrored: (e) ->
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|||||||
@ -1184,3 +1184,5 @@ Config =
|
|||||||
cachedTitles: [[]]
|
cachedTitles: [[]]
|
||||||
|
|
||||||
passMessageClosed: false
|
passMessageClosed: false
|
||||||
|
|
||||||
|
'Prerequest Captcha': false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user