diff --git a/4chan_x.user.js b/4chan_x.user.js index e26cc636f..ad0b64992 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1238,6 +1238,7 @@ $.append(d.body, iframe); $.bind(window, 'message', qr.message); $('#recaptcha_response_field').id = ''; + $.bind($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode); return qr.captcha = []; }, attach: function() { @@ -1270,6 +1271,15 @@ return (_ref = $('#autohide:checked', qr.el)) != null ? _ref.click() : void 0; } }, + captchaNode: function(e) { + var target; + if (!qr.el) { + return; + } + target = e.target; + $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value; + return $('#recaptcha_challenge_field', qr.el).value = target.value; + }, cb: { autohide: function(e) { if (this.checked) { @@ -2471,7 +2481,6 @@ el = _ref2[_i]; el.tabIndex = 1; } - $.bind($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', Recaptcha.reloaded); return $.bind($('#recaptcha_response_field'), 'keydown', Recaptcha.listener); }, listener: function(e) { @@ -2488,15 +2497,6 @@ }, reload: function() { return window.location = 'javascript:Recaptcha.reload()'; - }, - reloaded: function(e) { - var target; - if (!qr.el) { - return; - } - target = e.target; - $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value; - return $('#recaptcha_challenge_field', qr.el).value = target.value; } }; nodeInserted = function(e) { diff --git a/script.coffee b/script.coffee index a08391419..d87a49509 100644 --- a/script.coffee +++ b/script.coffee @@ -979,6 +979,8 @@ qr = #hack - nuke id so it doesn't grab focus when reloading $('#recaptcha_response_field').id = '' + + $.bind $('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode qr.captcha = [] attach: -> @@ -1001,6 +1003,12 @@ qr = unset: -> $('#autohide:checked', qr.el)?.click() + captchaNode: (e) -> + return unless qr.el + {target} = e + $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value + $('#recaptcha_challenge_field', qr.el).value = target.value + cb: autohide: (e) -> if @checked @@ -1882,7 +1890,6 @@ Recaptcha = #hack to tab from comment straight to recaptcha for el in $$ '#recaptcha_table a' el.tabIndex = 1 - $.bind $('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', Recaptcha.reloaded $.bind $('#recaptcha_response_field'), 'keydown', Recaptcha.listener listener: (e) -> if e.keyCode is 8 and @value is '' # backspace to reload @@ -1893,11 +1900,6 @@ Recaptcha = qr.push.call this reload: -> window.location = 'javascript:Recaptcha.reload()' - reloaded: (e) -> - return unless qr.el - {target} = e - $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value - $('#recaptcha_challenge_field', qr.el).value = target.value nodeInserted = (e) -> {target} = e