diff --git a/4chan_x.user.js b/4chan_x.user.js index 708230e83..545fca2be 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1301,7 +1301,7 @@ return $.bind(quote, 'click', qr.cb.quote); }, submit: function(e) { - var id, op; + var id, inputfile, isQR, op; if ($.config('Auto Watch Reply') && $.config('Thread Watcher')) { if (g.REPLY && $('img.favicon').src === Favicon.empty) { watcher.watch(null, g.THREAD_ID); @@ -1313,7 +1313,16 @@ } } } - if (this.id === 'qr_form') { + isQR = this.id === 'qr_form'; + inputfile = $('input[type=file]', this); + if (inputfile.value && inputfile.files[0].size > $('input[name=MAX_FILE_SIZE]').value) { + e.preventDefault(); + if (isQR) { + return $('#error').textContent = 'Error: File too large.'; + } else { + return alert('Error: File too large.'); + } + } else if (isQR) { $('#error').textContent = ''; qr.autohide.set(); return qr.sage = /sage/i.test($('input[name=email]', this).value); @@ -1355,8 +1364,7 @@ return f.innerHTML = f.innerHTML; }, 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; + var THREAD_ID, c, challenge, dialog, html, m, mail, name, pass, spoiler, src, submitDisabled, submitValue; submitValue = $('#com_submit').value; submitDisabled = $('#com_submit').disabled ? 'disabled' : ''; THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; @@ -1366,7 +1374,7 @@ 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 = "