From 8894e35ecec23b451abed5ba673c177c5b7cfc13 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 10 Aug 2011 21:18:40 -0700 Subject: [PATCH] captcha input: -required --- 4chan_x.user.js | 12 ++++++++++-- script.coffee | 10 +++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6ec61fc8b..909c43bdc 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1268,7 +1268,8 @@ } $('#recaptcha_challenge_field', qr.el).value = captcha.challenge; responseField.value = captcha.response; - return qr.submit.call($('form', qr.el)); + qr.submit.call($('form', qr.el)); + return true; }, captchaNode: function(e) { var target; @@ -1315,7 +1316,7 @@ THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; spoiler = $('.postarea label') ? '' : ''; challenge = $('#recaptcha_challenge_field').value; - html = " X
Quick Reply
" + spoiler + "
" + ($.get('captchas', []).length) + " captchas
attach another file
"; + html = " X
Quick Reply
" + spoiler + "
" + ($.get('captchas', []).length) + " captchas
attach another file
"; qr.el = ui.dialog('qr', { top: '0px', left: '0px' @@ -1411,6 +1412,13 @@ }, submit: function(e) { var id, isQR, op; + if ($('#recaptcha_response_field', qr.el).value === '') { + e.preventDefault(); + if (!qr.autoPost()) { + alert('You forgot to type in the verification.'); + } + return; + } if (conf['Auto Watch Reply'] && conf['Thread Watcher']) { if (g.REPLY && $('img.favicon').src === Favicon.empty) { watcher.watch(null, g.THREAD_ID); diff --git a/script.coffee b/script.coffee index f1e87544a..29c986966 100644 --- a/script.coffee +++ b/script.coffee @@ -1011,6 +1011,8 @@ qr = responseField.value = captcha.response qr.submit.call $ 'form', qr.el + true + captchaNode: (e) -> return unless qr.el {target} = e @@ -1062,7 +1064,7 @@ qr =
-
#{$.get('captchas', []).length} captchas
+
#{$.get('captchas', []).length} captchas
@@ -1152,6 +1154,12 @@ qr = $('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value submit: (e) -> + if $('#recaptcha_response_field', qr.el).value is '' + e.preventDefault() + unless qr.autoPost() + alert 'You forgot to type in the verification.' + return + if conf['Auto Watch Reply'] and conf['Thread Watcher'] if g.REPLY and $('img.favicon').src is Favicon.empty watcher.watch null, g.THREAD_ID