diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b666749..0602e5871 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,9 @@ Sometimes the changelog has notes (not comprehensive) acknowledging people's wor ### v1.11.13 +**v1.11.13.11** *(2015-10-30)* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.13.11/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.13.11/builds/4chan-X-noupdate.crx "Chromium version")] +- Work around captcha bug causing captcha to go offscreen to the right. + **v1.11.13.10** *(2015-10-25)* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.13.10/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.13.10/builds/4chan-X-noupdate.crx "Chromium version")] - (MayhemYDG) Update archive list: Update fireden.net and remove poweredby.moe. diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index 57dfe0ffa..abce1d18b 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -34,6 +34,8 @@ Captcha.v2 = $.on window, 'captcha:success', => # XXX Greasemonkey 1.x workaround to gain access to GM_* functions. $.queueTask => @save false + new MutationObserver(@watchBubbles.bind @).observe d.body, + childList: true initFrame: -> if token = $('.fbc-verification-token > textarea')?.value @@ -228,3 +230,20 @@ Captcha.v2 = window.grecaptcha.reset(container.dataset.widgetID); })(); ''' + + watchBubbles: (mutations) -> + for mutation in mutations + for node in mutation.addedNodes + if $ 'iframe[src^="https://www.google.com/recaptcha/api2/frame"]', node + new MutationObserver(@fixBubble.bind(@, node)).observe node, + attributes: true + + fixBubble: (node) -> + {bottom, right, width} = node.getBoundingClientRect() + if ( + bottom > 0 and # not deliberately offscreen + right > doc.clientWidth # offscreen to right + ) + qrLeft = QR.nodes.el.getBoundingClientRect().left + newLeft = Math.max 0, qrLeft - width + node.style.left = "#{newLeft}px"