diff --git a/4chan_x.user.js b/4chan_x.user.js index ea75571b6..d6f9784c8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -6417,7 +6417,7 @@ }; callbacks = { onload: function() { - return QR.response(this.response); + return QR.response(this); }, onerror: function() { delete QR.ajax; @@ -6447,11 +6447,11 @@ }; return QR.ajax = $.ajax($.id('postForm').parentNode.action, callbacks, opts); }, - response: function(html) { + response: function(req) { var ban, board, err, h1, persona, postID, reply, threadID, tmpDoc, _, _ref, _ref1; delete QR.ajax; tmpDoc = d.implementation.createHTMLDocument(''); - tmpDoc.documentElement.innerHTML = html; + tmpDoc.documentElement.innerHTML = req.response; if (ban = $('.banType', tmpDoc)) { board = $('.board', tmpDoc).innerHTML; err = $.el('span', { @@ -6463,6 +6463,8 @@ } } else if (tmpDoc.title !== 'Post successful!') { err = 'Connection error with sys.4chan.org.'; + } else if (req.status !== 200) { + err = "Error " + req.statusText + " (" + req.status + ")"; } if (err) { if (/captcha|verification/i.test(err.textContent) || err === 'Connection error with sys.4chan.org.') { diff --git a/src/qr.coffee b/src/qr.coffee index e752b34a9..89f455e8a 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -720,7 +720,7 @@ QR = callbacks = onload: -> - QR.response @response + QR.response @ onerror: -> delete QR.ajax # Connection error, or @@ -743,11 +743,11 @@ QR = QR.ajax = $.ajax $.id('postForm').parentNode.action, callbacks, opts - response: (html) -> + response: (req) -> delete QR.ajax tmpDoc = d.implementation.createHTMLDocument '' - tmpDoc.documentElement.innerHTML = html + tmpDoc.documentElement.innerHTML = req.response if ban = $ '.banType', tmpDoc # banned/warning board = $('.board', tmpDoc).innerHTML err = $.el 'span', innerHTML: @@ -761,6 +761,8 @@ QR = $('a', err)?.target = '_blank' # duplicate image link else if tmpDoc.title isnt 'Post successful!' err = 'Connection error with sys.4chan.org.' + else if req.status isnt 200 + err = "Error #{req.statusText} (#{req.status})" if err if /captcha|verification/i.test(err.textContent) or err is 'Connection error with sys.4chan.org.'