Improve accuracy of determining that comment is only a quote and thus captcha should not be opened yet. #2421, #2431
This commit is contained in:
parent
4ecee3fa1a
commit
582edf9442
@ -14,7 +14,7 @@ Captcha.cache =
|
||||
not (
|
||||
@haveCookie() or @captchas.length or QR.req or @submitCB
|
||||
) 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 !QR.posts[0].isOnlyQuotes() or QR.posts[0].file
|
||||
)
|
||||
|
||||
needed: ->
|
||||
@ -31,7 +31,7 @@ Captcha.cache =
|
||||
!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 '')
|
||||
!QR.selected.isOnlyQuotes()
|
||||
)
|
||||
isReply = (QR.selected.thread isnt 'new')
|
||||
if !$.event('RequestCaptcha', {isReply})
|
||||
|
||||
@ -329,6 +329,8 @@ QR =
|
||||
{com, thread} = QR.nodes
|
||||
thread.value = Get.threadFromNode @ unless com.value
|
||||
|
||||
wasOnlyQuotes = QR.selected.isOnlyQuotes()
|
||||
|
||||
caretPos = com.selectionStart
|
||||
# Replace selection for text.
|
||||
com.value = com.value[...caretPos] + text + com.value[com.selectionEnd..]
|
||||
@ -337,6 +339,9 @@ QR =
|
||||
com.setSelectionRange range, range
|
||||
com.focus()
|
||||
|
||||
# This allows us to determine if any text other than quotes has been typed.
|
||||
QR.selected.quotedText = com.value if wasOnlyQuotes
|
||||
|
||||
QR.selected.save com
|
||||
QR.selected.save thread
|
||||
|
||||
@ -654,6 +659,7 @@ QR =
|
||||
return
|
||||
|
||||
post = QR.posts[0]
|
||||
delete post.quotedText
|
||||
post.forceSave()
|
||||
threadID = post.thread
|
||||
thread = g.BOARD.threads.get(threadID)
|
||||
|
||||
@ -169,6 +169,9 @@ QR.post = class
|
||||
QR.captcha.moreNeeded()
|
||||
Captcha.cache.prerequest()
|
||||
|
||||
isOnlyQuotes: ->
|
||||
(@com or '').trim() is (@quotedText or '').trim()
|
||||
|
||||
@rmErrored: (e) ->
|
||||
e.stopPropagation()
|
||||
for post in QR.posts by -1 when errors = post.errors
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user