diff --git a/4chan_x.js b/4chan_x.js index 01f878e47..96f716e14 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -990,6 +990,7 @@ $.remove(dialog); } } + g.seconds = g.sage ? 60 : 30; qr.cooldownStart(); } else { error = $.el('span', { @@ -1016,6 +1017,17 @@ if (span = this.nextSibling) { $.remove(span); } + if (g.seconds = GM_getValue('seconds')) { + e.preventDefault(); + span = $.el('span', { + className: 'error', + textContent: 'Stop posting so often!' + }); + $.append(this.parentNode, span); + alert('Stop posting so often!'); + qr.cooldownStart(); + return; + } recaptcha = $('input[name=recaptcha_response_field]', this); if (recaptcha.value) { qr.autohide.set(); @@ -1070,6 +1082,7 @@ submit.value = 'Submit'; } else { submit.value = g.seconds = g.seconds - 1; + GM_setValue('seconds', g.seconds); } } if (g.seconds !== 0) { @@ -1078,7 +1091,7 @@ }, cooldownStart: function() { var submit, submits, _i, _len; - g.seconds = g.sage ? 60 : 30; + GM_setValue('seconds', g.seconds); submits = $$('#qr input[type=submit], form[name=post] input[type=submit]'); for (_i = 0, _len = submits.length; _i < _len; _i++) { submit = submits[_i]; diff --git a/script.coffee b/script.coffee index b8e947bb8..6d7d093a9 100644 --- a/script.coffee +++ b/script.coffee @@ -730,6 +730,7 @@ qr = qr.refresh dialog else $.remove dialog + g.seconds = if g.sage then 60 else 30 qr.cooldownStart() else error = $.el 'span', @@ -748,6 +749,17 @@ qr = submit: (e) -> if span = @nextSibling $.remove span + + if g.seconds = GM_getValue 'seconds' + e.preventDefault() + span = $.el 'span', + className: 'error' + textContent: 'Stop posting so often!' + $.append @parentNode, span + alert 'Stop posting so often!' + qr.cooldownStart() + return + recaptcha = $('input[name=recaptcha_response_field]', this) if recaptcha.value qr.autohide.set() @@ -796,12 +808,13 @@ qr = submit.value = 'Submit' else submit.value = g.seconds = g.seconds - 1 + GM_setValue 'seconds', g.seconds if g.seconds != 0 window.setTimeout qr.cooldown, 1000 cooldownStart: -> - g.seconds = if g.sage then 60 else 30 + GM_setValue 'seconds', g.seconds submits = $$ '#qr input[type=submit], form[name=post] input[type=submit]' for submit in submits submit.value = g.seconds