diff --git a/CHANGELOG.md b/CHANGELOG.md index d7094fc9e..8904771ae 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,14 @@ Based on v1.9.14.2. - Bug fixes. +### v1.9.14.6 +*2014-12-08* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.14.6/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.14.6/builds/4chan-X-noupdate.crx "Chromium version")] + +**ccd0** +- Fix some captcha bugs. +- The QR now focuses on the submit button after captcha completion, unless you are dumping and more captchas are needed. +- Fix updater bugs introduced in v1.9.14.0. + ### v1.9.14.5 *2014-12-08* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.14.5/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.14.5/builds/4chan-X-noupdate.crx "Chromium version")] diff --git a/src/General/css/style.css b/src/General/css/style.css index f4e2c3a6f..9aa483492 100755 --- a/src/General/css/style.css +++ b/src/General/css/style.css @@ -1066,7 +1066,7 @@ input.field.tripped:not(:hover):not(:focus) { #qr textarea { resize: both; } -#qr .captcha-section { +#qr .captcha-root { position: relative; } #qr .captcha-container > div > div { diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index 4706c4cca..f6398bdad 100755 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -320,6 +320,7 @@ ThreadUpdater = ThreadUpdater.root.getBoundingClientRect().bottom - doc.clientHeight < 25 for post in posts + root = post.nodes.root unless QuoteThreading.insert post $.add ThreadUpdater.root, post.nodes.root $.event 'PostsInserted' diff --git a/src/Posting/QR.captcha.coffee b/src/Posting/QR.captcha.coffee index e098ecc74..75b1d424a 100644 --- a/src/Posting/QR.captcha.coffee +++ b/src/Posting/QR.captcha.coffee @@ -8,17 +8,17 @@ QR.captcha = QR.captcha.sync captchas $.sync 'captchas', @sync.bind @ - section = $.el 'div', className: 'captcha-section' - $.extend section, <%= html( + root = $.el 'div', className: 'captcha-root' + $.extend root, <%= html( '
' + '' ) %> - container = $ '.captcha-container', section - counter = $ '.captcha-counter > a', section + container = $ '.captcha-container', root + counter = $ '.captcha-counter > a', root @nodes = {container, counter} @count() $.addClass QR.nodes.el, 'has-captcha' - $.after QR.nodes.com.parentNode, section + $.after QR.nodes.com.parentNode, root new MutationObserver(@afterSetup.bind @).observe container, childList: true @@ -29,29 +29,37 @@ QR.captcha = shouldFocus: false timeouts: {} + postsCount: 0 + + 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 - 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 + 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 + + onPostChange: -> + @setup() if @postsCount is 0 toggle: -> - if @nodes.container.dataset.widgetID and !@timeouts.destroy + if @occupied() @destroy() else - @shouldFocus = true - @setup true + @setup true, true - setup: (force) -> + setup: (focus, force) -> return unless @isEnabled and (@needed() or force) $.addClass QR.nodes.el, 'captcha-open' + @shouldFocus = true if focus if @timeouts.destroy 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"); @@ -99,11 +107,11 @@ QR.captcha = null save: (e) -> - if @needed() + if QR.cooldown.auto and @needed() @shouldFocus = true @reload() else - @nodes.counter.focus() + QR.nodes.status.focus() @timeouts.destroy ?= setTimeout @destroy.bind(@), 3 * $.SECOND $.forceSync 'captchas' @captchas.push @@ -121,7 +129,7 @@ QR.captcha = @captchas = @captchas[i..] @count() $.set 'captchas', @captchas - @setup() + @setup true count: -> @nodes.counter.textContent = "Captchas: #{@captchas.length}" diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 09db4af22..88cf9865e 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -145,7 +145,7 @@ QR = el = err el.removeAttribute 'style' if QR.captcha.isEnabled and /captcha|verification/i.test el.textContent - QR.captcha.setup() + QR.captcha.setup true QR.notify el alert el.textContent if d.hidden @@ -813,7 +813,7 @@ QR = QR.close() else post.rm() - QR.captcha.setup() + QR.captcha.setup true QR.cooldown.add req.uploadEndTime, threadID, postID diff --git a/src/Posting/QR.post.coffee b/src/Posting/QR.post.coffee index b228642a1..ef7a4da22 100644 --- a/src/Posting/QR.post.coffee +++ b/src/Posting/QR.post.coffee @@ -37,7 +37,6 @@ QR.post = class prev = QR.posts[QR.posts.length - 1] QR.posts.push @ - QR.captcha.setup() @nodes.spoiler.checked = @spoiler = if prev and Conf['Remember Spoiler'] prev.spoiler else @@ -70,6 +69,8 @@ QR.post = class @load() if QR.selected is @ # load persona @select() if select @unlock() + # Post count temporarily off by 1 when called from QR.post.rm + $.queueTask -> QR.captcha.setup() rm: -> @delete() @@ -132,7 +133,7 @@ QR.post = class QR.status() when 'com' @nodes.span.textContent = @com - QR.captcha.setup() + QR.captcha.onPostChange() QR.characterCount() # Disable auto-posting if you're typing in the first post # during the last 5 seconds of the cooldown. @@ -161,7 +162,7 @@ QR.post = class @filename = file.name @filesize = $.bytesToString file.size @nodes.label.hidden = false if QR.spoiler - QR.captcha.setup() + QR.captcha.onPostChange() URL.revokeObjectURL @URL if @ is QR.selected @showFileData()