From cf8b73eaf53676e351ee572a26373b52400e713c Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 18 Jun 2013 22:18:32 +0200 Subject: [PATCH] Fix support for the report window. --- 4chan_x.user.js | 12 ++++++++---- script.coffee | 7 +++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4e6e32f8b..caa19d14e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -5484,7 +5484,7 @@ Main = { init: function() { - var key, path, pathname, settings, temp, val; + var asap, key, path, pathname, settings, temp, val; Main.flatten(null, Config); path = location.pathname; pathname = path.slice(1).split('/'); @@ -5504,10 +5504,13 @@ switch (location.hostname) { case 'sys.4chan.org': if (/report/.test(location.search)) { - $.ready(function() { + asap = function() { var field, form; + if (!(field = $.id('recaptcha_response_field'))) { + setTimeout(asap, 200); + return; + } form = $('form'); - field = $.id('recaptcha_response_field'); $.on(field, 'keydown', function(e) { if (e.keyCode === 8 && !e.target.value) { return window.location = 'javascript:Recaptcha.reload()'; @@ -5522,7 +5525,8 @@ } return form.submit(); }); - }); + }; + asap(); } return; case 'images.4chan.org': diff --git a/script.coffee b/script.coffee index d2101622a..e9d589403 100644 --- a/script.coffee +++ b/script.coffee @@ -4434,9 +4434,11 @@ Main = switch location.hostname when 'sys.4chan.org' if /report/.test location.search - $.ready -> + asap = -> + unless field = $.id 'recaptcha_response_field' + setTimeout asap, 200 + return form = $ 'form' - field = $.id 'recaptcha_response_field' $.on field, 'keydown', (e) -> window.location = 'javascript:Recaptcha.reload()' if e.keyCode is 8 and not e.target.value $.on form, 'submit', (e) -> @@ -4444,6 +4446,7 @@ Main = response = field.value.trim() field.value = "#{response} #{response}" unless /\s/.test response form.submit() + asap() return when 'images.4chan.org' $.ready ->