From 5ffb6168cb9475c995790531ec6d5455b1c24d0d Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 14 Dec 2012 18:13:15 +0100 Subject: [PATCH] Fix warning. --- 4chan_x.user.js | 8 ++++---- changelog | 1 + script.coffee | 17 +++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 06b61ae35..8675b5f67 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2609,13 +2609,13 @@ return QR.ajax = $.ajax($.id('postForm').parentNode.action, callbacks, opts); }, response: function(html) { - var bs, doc, err, msg, persona, postID, reply, threadID, _, _ref, _ref1; + var ban, board, doc, err, msg, persona, postID, reply, threadID, _, _ref, _ref1; doc = d.implementation.createHTMLDocument(''); doc.documentElement.innerHTML = html; - if (doc.title === '4chan - Banned') { - bs = $$('b', doc); + if (ban = $('.banType', doc)) { + board = $('.board', doc).innerHTML; err = $.el('span', { - innerHTML: /^You were issued a warning/.test($('.boxcontent', doc).textContent.trim()) ? "You were issued a warning on " + bs[0].innerHTML + " as " + bs[3].innerHTML + ".
Warning reason: " + bs[1].innerHTML : "You are banned! ;_;
Please click HERE to see the reason." + innerHTML: ban.textContent.toLowerCase() === 'banned' ? ("You are banned on " + board + "! ;_;
") + "Click here to see the reason." : ("You were issued a warning on " + board + " as " + ($('.nameBlock', doc).innerHTML) + ".
") + ("Reason: " + ($('.reason', doc).innerHTML)) }); } else if (err = doc.getElementById('errmsg')) { if ((_ref = $('a', err)) != null) { diff --git a/changelog b/changelog index e8ac104b4..f461f3f50 100644 --- a/changelog +++ b/changelog @@ -2,6 +2,7 @@ master - Mayhem Fix selection quoting on Opera. Fix history bug with Persistent QR enabled on Chrome. + Fix posting warning not displaying the reason. 2.37.0 - noface diff --git a/script.coffee b/script.coffee index 8db247473..405755095 100644 --- a/script.coffee +++ b/script.coffee @@ -2058,14 +2058,15 @@ QR = response: (html) -> doc = d.implementation.createHTMLDocument '' doc.documentElement.innerHTML = html - if doc.title is '4chan - Banned' # Ban/warn check - bs = $$ 'b', doc - err = $.el 'span', - innerHTML: - if /^You were issued a warning/.test $('.boxcontent', doc).textContent.trim() - "You were issued a warning on #{bs[0].innerHTML} as #{bs[3].innerHTML}.
Warning reason: #{bs[1].innerHTML}" - else - "You are banned! ;_;
Please click HERE to see the reason." + if ban = $ '.banType', doc # banned/warning + board = $('.board', doc).innerHTML + err = $.el 'span', innerHTML: + if ban.textContent.toLowerCase() is 'banned' + "You are banned on #{board}! ;_;
" + + "Click here to see the reason." + else + "You were issued a warning on #{board} as #{$('.nameBlock', doc).innerHTML}.
" + + "Reason: #{$('.reason', doc).innerHTML}" else if err = doc.getElementById 'errmsg' # error! $('a', err)?.target = '_blank' # duplicate image link else unless msg = $ 'b', doc