From 01592ae8d773850e98dd6ce29ad8127e069e3ad2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 9 Aug 2011 04:38:59 -0700 Subject: [PATCH] autopost timeout try to not look like a spambot --- 4chan_x.user.js | 19 ++++++++----------- script.coffee | 15 ++++++--------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fde3c4a54..488b9ed34 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1263,12 +1263,13 @@ }, autoPost: function() { var captcha, responseField; - responseField = $('#recaptcha_response_field', qr.el); - if (!responseField.value && (captcha = qr.captcha.shift())) { - $('#recaptcha_challenge_field', qr.el).value = captcha.challenge; - responseField.value = captcha.response; - responseField.nextSibling.textContent = qr.captcha.length + ' captcha cached'; + if (!(captcha = qr.captcha.shift())) { + return; } + $('#recaptcha_challenge_field', qr.el).value = captcha.challenge; + responseField = $('#recaptcha_response_field', qr.el); + responseField.value = captcha.response; + responseField.nextSibling.textContent = qr.captcha.length + ' captcha cached'; return qr.submit.call($('form', qr.el)); }, captchaNode: function(e) { @@ -1341,15 +1342,11 @@ $('#recaptcha_response_field', qr.el).value = ''; $('#autohide', qr.el).checked = false; if (data.textContent === 'You seem to have mistyped the verification.') { - if (qr.captcha.length) { - qr.autoPost(); - } + setTimeout(qr.autoPost, 1000); } else if (data.textContent === 'Error: Duplicate file entry detected.' && qr.files.childElementCount) { $('textarea', qr.el).value += '\n' + data.textContent + ' ' + data.href; qr.attachNext(); - if (qr.captcha.length) { - qr.autoPost(); - } + setTimeout(qr.autoPost, 1000); } return; } diff --git a/script.coffee b/script.coffee index 74ed47244..236ea9b2f 100644 --- a/script.coffee +++ b/script.coffee @@ -970,7 +970,6 @@ qr = # error handling / logging # persistent captcha # rm Recaptcha - # error too large error should happen on attach init: -> g.callbacks.push qr.node $.bind window, 'message', qr.message @@ -999,11 +998,11 @@ qr = $.replace oldFile, file autoPost: -> + return unless captcha = qr.captcha.shift() + $('#recaptcha_challenge_field', qr.el).value = captcha.challenge responseField = $ '#recaptcha_response_field', qr.el - if !responseField.value and captcha = qr.captcha.shift() - $('#recaptcha_challenge_field', qr.el).value = captcha.challenge - responseField.value = captcha.response - responseField.nextSibling.textContent = qr.captcha.length + ' captcha cached' + responseField.value = captcha.response + responseField.nextSibling.textContent = qr.captcha.length + ' captcha cached' qr.submit.call $ 'form', qr.el captchaNode: (e) -> @@ -1086,13 +1085,11 @@ qr = $('#recaptcha_response_field', qr.el).value = '' $('#autohide', qr.el).checked = false if data.textContent is 'You seem to have mistyped the verification.' - if qr.captcha.length - qr.autoPost() + setTimeout qr.autoPost, 1000 else if data.textContent is 'Error: Duplicate file entry detected.' and qr.files.childElementCount $('textarea', qr.el).value += '\n' + data.textContent + ' ' + data.href qr.attachNext() - if qr.captcha.length - qr.autoPost() + setTimeout qr.autoPost, 1000 return if qr.el