From c94b08c1ab908ededd08a1ae0b80d17d474c826e Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 26 Jan 2012 06:48:59 +0100 Subject: [PATCH] Start auto-post on connection error when possible. Provide some feedback that we're starting to submit. --- 4chan_x.user.js | 12 ++++++++---- script.coffee | 16 +++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a55f9494e..6baeb3c68 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1678,6 +1678,9 @@ recaptcha_challenge_field: challenge, recaptcha_response_field: response }; + qr.status({ + progress: '...' + }); if (engine === 'gecko' && reply.file) { file = {}; reader = new FileReader(); @@ -1702,18 +1705,19 @@ } else if (b.childElementCount) { if (b.firstChild.tagName) node = b.firstChild; err = b.firstChild.textContent; - if (err === 'You seem to have mistyped the verification.') { + } + if (err) { + if (err === 'You seem to have mistyped the verification.' || err === 'Connection error with sys.4chan.org.') { qr.cooldown.auto = !!$.get('captchas', []).length; qr.cooldown.set(10); } else { qr.cooldown.auto = false; } - } - qr.status(); - if (err) { + qr.status(); qr.error(err, node); return; } + qr.status(); reply = qr.replies[0]; persona = $.get('qr.persona', {}); persona = { diff --git a/script.coffee b/script.coffee index f801898aa..42265a432 100644 --- a/script.coffee +++ b/script.coffee @@ -1252,6 +1252,10 @@ qr = recaptcha_challenge_field: challenge recaptcha_response_field: response + # Starting to upload might take some time. + # Provide some feedback that we're starting to submit. + qr.status progress: '...' + if engine is 'gecko' and reply.file # https://bugzilla.mozilla.org/show_bug.cgi?id=673742 # We plan to allow postMessaging Files and FileLists across origins, @@ -1275,20 +1279,22 @@ qr = else if b.childElementCount # error! node = b.firstChild if b.firstChild.tagName # duplicate image link err = b.firstChild.textContent - if err is 'You seem to have mistyped the verification.' + + if err + if err is 'You seem to have mistyped the verification.' or err is 'Connection error with sys.4chan.org.' # Enable auto-post if we have some cached captchas. qr.cooldown.auto = !!$.get('captchas', []).length # Too many frequent mistyped captchas will auto-ban you! + # On connection error, the post most likely didn't go through. qr.cooldown.set 10 else # stop auto-posting qr.cooldown.auto = false - - qr.status() - - if err + qr.status() qr.error err, node return + qr.status() + reply = qr.replies[0] persona = $.get 'qr.persona', {}