Avoid double loading of captcha image.

This commit is contained in:
ccd0 2014-12-22 08:47:48 -08:00
parent 7908110c63
commit 98b392480a

View File

@ -39,16 +39,21 @@ Captcha.noscript =
@setup() @setup()
initFrame: -> initFrame: ->
img = $ '.fbc-payload > img'
sendChallenge = ->
if img.complete
conn.send {challenge: img.src}
else
$.on img, 'load', -> conn.send {challenge: img.src}
conn = new Connection window.top, "#{location.protocol}//boards.4chan.org", conn = new Connection window.top, "#{location.protocol}//boards.4chan.org",
queryChallenge: -> queryChallenge: sendChallenge
conn.send {challenge}
response: (response) -> response: (response) ->
$.id('response').value = response $.id('response').value = response
$('.fbc-challenge > form').submit() $('.fbc-challenge > form').submit()
challenge = $('.fbc-payload > img')?.src conn.send
token = $('.fbc-verification-token > textarea')?.value token: $('.fbc-verification-token > textarea')?.value
error = $('.fbc-error')?.textContent error: $('.fbc-error')?.textContent
conn.send {challenge, token, error} sendChallenge() if img
timers: {} timers: {}