From 4efe9d2f324ec928999b59a39248381242228320 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 9 Jun 2012 02:12:43 +0200 Subject: [PATCH] Captchas now last only 5 minutes. --- 4chan_x.user.js | 6 ++++-- changelog | 2 ++ script.coffee | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index f5c3244e9..bd8ac7424 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1834,11 +1834,13 @@ }, load: function() { var challenge; - this.timeout = Date.now() + 26 * $.MINUTE; + this.timeout = Date.now() + 4 * $.MINUTE; challenge = this.challenge.firstChild.value; this.img.alt = challenge; this.img.src = "//www.google.com/recaptcha/api/image?c=" + challenge; - return this.input.value = null; + this.input.value = null; + clearTimeout(this.timeoutID); + return this.timeoutID = setTimeout(this.reload, 4 * $.MINUTE); }, count: function(count) { this.input.placeholder = (function() { diff --git a/changelog b/changelog index d5b4f8b97..171b7f308 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- Mayhem + Update captcha longevity to 5 minutes max, as according to 4chan's change. 2.31.5 - Mayhem diff --git a/script.coffee b/script.coffee index a0ed7751b..178b6fe42 100644 --- a/script.coffee +++ b/script.coffee @@ -1357,12 +1357,18 @@ QR = @count captchas.length @reload() load: -> - # Timeout is available at RecaptchaState.timeout in seconds. - @timeout = Date.now() + 26*$.MINUTE + # Timeout was available at RecaptchaState.timeout in seconds. + # Timeout is now set by moot: 5 minutes. + # We use 5-1 minutes to give upload some time. + @timeout = Date.now() + 4*$.MINUTE challenge = @challenge.firstChild.value @img.alt = challenge @img.src = "//www.google.com/recaptcha/api/image?c=#{challenge}" @input.value = null + # Refresh captchas every 4 minutes to avoid filling perished ones. + # This used to be done by the recaptcha script, but it doesn't take into account moot's custom value. + clearTimeout @timeoutID + @timeoutID = setTimeout @reload, 4*$.MINUTE count: (count) -> @input.placeholder = switch count when 0