From 7f32648ed0e837c0adb44e08527837e606526470 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 8 Dec 2014 17:25:18 -0800 Subject: [PATCH] Better detection of when the captcha is open. Old version didn't detect the noscript version that sometimes comes up. --- src/Posting/QR.captcha.coffee | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Posting/QR.captcha.coffee b/src/Posting/QR.captcha.coffee index e098ecc74..53921560a 100644 --- a/src/Posting/QR.captcha.coffee +++ b/src/Posting/QR.captcha.coffee @@ -30,15 +30,19 @@ QR.captcha = shouldFocus: false timeouts: {} + occupied: -> + {container} = @nodes + (container.firstChild or container.dataset.widgetID) and !@timeouts.destroy + needed: -> captchaCount = @captchas.length - captchaCount++ if @nodes.container.dataset.widgetID and !@timeouts.destroy + captchaCount++ if @occupied() postsCount = QR.posts.length postsCount = 0 if postsCount is 1 and !Conf['Auto-load captcha'] and !QR.posts[0].com and !QR.posts[0].file captchaCount < postsCount toggle: -> - if @nodes.container.dataset.widgetID and !@timeouts.destroy + if @occupied() @destroy() else @shouldFocus = true @@ -51,7 +55,7 @@ QR.captcha = clearTimeout @timeouts.destroy delete @timeouts.destroy return @reload() - return if @nodes.container.dataset.widgetID + return if @occupied() $.globalEval ''' (function() { var container = document.querySelector("#qr .captcha-container");