From de96f664516cb7bdb566d7cc9c4bf2813724ab06 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 24 May 2011 18:14:13 +0200 Subject: [PATCH 1/4] Fix cooldown. --- 4chan_x.js | 18 ++++++------------ script.coffee | 14 ++++++-------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 25395feba..0e5f6eeef 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -85,7 +85,7 @@ 'Sauce': [true, 'Add sauce to images'] }, post: { - 'Cooldown': [false, 'Prevent \'flood detected\' errors (buggy)'], + 'Cooldown': [true, 'Prevent \'flood detected\' errors (buggy)'], 'Quick Reply': [true, 'Reply without leaving the page'], 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'] }, @@ -1128,21 +1128,15 @@ return qr.duration = duration; }, cooldownCB: function() { - var submit, submits, _i, _len; - qr.duration = qr.duration - 1; + var submit, submits, _i, _len, _results; + qr.duration--; submits = $$('#com_submit'); + _results = []; for (_i = 0, _len = submits.length; _i < _len; _i++) { submit = submits[_i]; - if (qr.duration === 0) { - submit.disabled = false; - submit.value = 'Submit'; - } else { - submit.value = qr.duration; - } - } - if (qr.duration === 0) { - return clearInterval(qr.cooldownIntervalID); + _results.push(qr.duration ? submit.value = qr.duration : (submit.disabled = false, submit.value = 'Submit', window.clearInterval(qr.cooldownIntervalID))); } + return _results; }, dialog: function(link) { var MAX_FILE_SIZE, THREAD_ID, c, challenge, dialog, html, m, mail, name, pass, spoiler, src; diff --git a/script.coffee b/script.coffee index 5fb8513cb..674613be3 100644 --- a/script.coffee +++ b/script.coffee @@ -26,7 +26,7 @@ config = 'Image Preloading': [false, 'Preload Images'] 'Sauce': [true, 'Add sauce to images'] post: - 'Cooldown': [false, 'Prevent \'flood detected\' errors (buggy)'] + 'Cooldown': [true, 'Prevent \'flood detected\' errors (buggy)'] 'Quick Reply': [true, 'Reply without leaving the page'] 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'] quote: @@ -887,18 +887,16 @@ qr = qr.duration = duration cooldownCB: -> - qr.duration = qr.duration - 1 + qr.duration-- submits = $$ '#com_submit' for submit in submits - if qr.duration == 0 + if qr.duration + submit.value = qr.duration + else submit.disabled = false submit.value = 'Submit' - else - submit.value = qr.duration - - if qr.duration == 0 - clearInterval qr.cooldownIntervalID + window.clearInterval qr.cooldownIntervalID dialog: (link) -> #maybe should be global From 227a6cef0a86669e0a25de16135f46675a4b6ae9 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 24 May 2011 20:06:22 +0200 Subject: [PATCH 2/4] Actually fix the cooldown, fix the enabled qr on 404. --- 4chan_x.js | 22 +++++++++++++++------- script.coffee | 10 +++++++--- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 0e5f6eeef..14ffb1cd6 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -85,7 +85,7 @@ 'Sauce': [true, 'Add sauce to images'] }, post: { - 'Cooldown': [true, 'Prevent \'flood detected\' errors (buggy)'], + 'Cooldown': [true, 'Prevent \'flood detected\' errors'], 'Quick Reply': [true, 'Reply without leaving the page'], 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'] }, @@ -1128,19 +1128,27 @@ return qr.duration = duration; }, cooldownCB: function() { - var submit, submits, _i, _len, _results; + var submit, submits, _i, _len; qr.duration--; submits = $$('#com_submit'); - _results = []; for (_i = 0, _len = submits.length; _i < _len; _i++) { submit = submits[_i]; - _results.push(qr.duration ? submit.value = qr.duration : (submit.disabled = false, submit.value = 'Submit', window.clearInterval(qr.cooldownIntervalID))); + if (qr.duration) { + submit.value = qr.duration; + } else { + submit.disabled = false; + submit.value = 'Submit'; + } + } + if (!qr.duration) { + return clearInterval(qr.cooldownIntervalID); } - return _results; }, dialog: function(link) { - var MAX_FILE_SIZE, THREAD_ID, c, challenge, dialog, html, m, mail, name, pass, spoiler, src; + var MAX_FILE_SIZE, THREAD_ID, c, challenge, dialog, html, m, mail, name, pass, spoiler, src, submitDisabled, submitValue; MAX_FILE_SIZE = $('input[name="MAX_FILE_SIZE"]').value; + submitValue = $('#com_submit').value; + submitDisabled = $('#com_submit').disabled ? 'disabled' : void 0; THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; challenge = $('input[name=recaptcha_challenge_field]').value; src = "http://www.google.com/recaptcha/api/image?c=" + challenge; @@ -1148,7 +1156,7 @@ name = (m = c.match(/4chan_name=([^;]+)/)) ? unescape(m[1]) : ''; mail = (m = c.match(/4chan_email=([^;]+)/)) ? unescape(m[1]) : ''; pass = (m = c.match(/4chan_pass=([^;]+)/)) ? unescape(m[1]) : $('input[name=pwd]').value; - html = "
Quick Reply X
"; + html = "
Quick Reply X
"; dialog = ui.dialog('qr', { top: '0px', left: '0px' diff --git a/script.coffee b/script.coffee index 674613be3..8902b10b6 100644 --- a/script.coffee +++ b/script.coffee @@ -26,7 +26,7 @@ config = 'Image Preloading': [false, 'Preload Images'] 'Sauce': [true, 'Add sauce to images'] post: - 'Cooldown': [true, 'Prevent \'flood detected\' errors (buggy)'] + 'Cooldown': [true, 'Prevent \'flood detected\' errors'] 'Quick Reply': [true, 'Reply without leaving the page'] 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'] quote: @@ -896,11 +896,15 @@ qr = else submit.disabled = false submit.value = 'Submit' - window.clearInterval qr.cooldownIntervalID + + clearInterval qr.cooldownIntervalID unless qr.duration + dialog: (link) -> #maybe should be global MAX_FILE_SIZE = $('input[name="MAX_FILE_SIZE"]').value + submitValue = $('#com_submit').value + submitDisabled = if $('#com_submit').disabled then 'disabled' #FIXME inlined cross-thread quotes THREAD_ID = g.THREAD_ID or $.x('ancestor::div[@class="thread"]/div', link).id challenge = $('input[name=recaptcha_challenge_field]').value @@ -921,7 +925,7 @@ qr =
-
+
From 4d746dce09ca35d668faa2ad6d13489e708b7acd Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 24 May 2011 20:44:47 +0200 Subject: [PATCH 3/4] Consistency --- 4chan_x.js | 6 +++--- script.coffee | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 14ffb1cd6..e35050d47 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1141,14 +1141,14 @@ } } if (!qr.duration) { - return clearInterval(qr.cooldownIntervalID); + return window.clearInterval(qr.cooldownIntervalID); } }, dialog: function(link) { var MAX_FILE_SIZE, THREAD_ID, c, challenge, dialog, html, m, mail, name, pass, spoiler, src, submitDisabled, submitValue; MAX_FILE_SIZE = $('input[name="MAX_FILE_SIZE"]').value; submitValue = $('#com_submit').value; - submitDisabled = $('#com_submit').disabled ? 'disabled' : void 0; + submitDisabled = $('#com_submit').disabled ? 'disabled' : ''; THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; challenge = $('input[name=recaptcha_challenge_field]').value; src = "http://www.google.com/recaptcha/api/image?c=" + challenge; @@ -1407,7 +1407,7 @@ count.textContent = 404; count.className = 'error'; timer.textContent = ''; - clearInterval(updater.intervalID); + window.clearInterval(updater.intervalID); _ref = $$('input[type=submit]'); for (_i = 0, _len = _ref.length; _i < _len; _i++) { input = _ref[_i]; diff --git a/script.coffee b/script.coffee index 8902b10b6..d85d04d1f 100644 --- a/script.coffee +++ b/script.coffee @@ -897,14 +897,14 @@ qr = submit.disabled = false submit.value = 'Submit' - clearInterval qr.cooldownIntervalID unless qr.duration + window.clearInterval qr.cooldownIntervalID unless qr.duration dialog: (link) -> #maybe should be global MAX_FILE_SIZE = $('input[name="MAX_FILE_SIZE"]').value submitValue = $('#com_submit').value - submitDisabled = if $('#com_submit').disabled then 'disabled' + submitDisabled = if $('#com_submit').disabled then 'disabled' else '' #FIXME inlined cross-thread quotes THREAD_ID = g.THREAD_ID or $.x('ancestor::div[@class="thread"]/div', link).id challenge = $('input[name=recaptcha_challenge_field]').value @@ -1156,7 +1156,7 @@ updater = count.textContent = 404 count.className = 'error' timer.textContent = '' - clearInterval updater.intervalID + window.clearInterval updater.intervalID for input in $$ 'input[type=submit]' input.disabled = true input.value = 404 From d88a7674ba0885e96a2d1a6a80d6f38958edfad6 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 24 May 2011 22:19:17 +0200 Subject: [PATCH 4/4] Fix moonrunes in cookies, and eventual 's in. --- 4chan_x.js | 8 ++++---- script.coffee | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index e35050d47..8f4ddb955 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1153,10 +1153,10 @@ challenge = $('input[name=recaptcha_challenge_field]').value; src = "http://www.google.com/recaptcha/api/image?c=" + challenge; c = d.cookie; - name = (m = c.match(/4chan_name=([^;]+)/)) ? unescape(m[1]) : ''; - mail = (m = c.match(/4chan_email=([^;]+)/)) ? unescape(m[1]) : ''; - pass = (m = c.match(/4chan_pass=([^;]+)/)) ? unescape(m[1]) : $('input[name=pwd]').value; - html = "
Quick Reply X
"; + name = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + mail = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; + pass = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; + html = "
Quick Reply X
"; dialog = ui.dialog('qr', { top: '0px', left: '0px' diff --git a/script.coffee b/script.coffee index d85d04d1f..35c78cf4e 100644 --- a/script.coffee +++ b/script.coffee @@ -910,12 +910,12 @@ qr = challenge = $('input[name=recaptcha_challenge_field]').value src = "http://www.google.com/recaptcha/api/image?c=#{challenge}" c = d.cookie - name = if m = c.match(/4chan_name=([^;]+)/) then unescape m[1] else '' - mail = if m = c.match(/4chan_email=([^;]+)/) then unescape m[1] else '' - pass = if m = c.match(/4chan_pass=([^;]+)/) then unescape m[1] else $('input[name=pwd]').value + name = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' + mail = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' + pass = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value html = "
- + Quick Reply X @@ -924,13 +924,13 @@ qr = -
+
-
+
"