From 63ffca71d5d1be46fe20035586e25e926f8607e1 Mon Sep 17 00:00:00 2001 From: noface Date: Fri, 16 Nov 2012 18:34:29 +0100 Subject: [PATCH] Add support for post with QR and tags on /f/. --- 4chan_x.user.js | 19 ++++++++++++++----- script.coffee | 27 +++++++++++++++++++++------ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fc17a2628..840dbdbe3 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1738,7 +1738,7 @@ $.on(link.firstChild, 'click', function() { QR.open(); if (!g.REPLY) { - QR.threadSelector.value = 'new'; + QR.threadSelector.value = g.BOARD !== 'f' ? 'new' : '9999'; } return $('textarea', QR.el).focus(); }); @@ -2418,10 +2418,10 @@ id = thread.id.slice(1); threads += ""; } - QR.threadSelector = $.el('select', { + QR.threadSelector = g.BOARD !== 'f' ? $.el('select', { innerHTML: threads, title: 'Create a new thread / Reply to a thread' - }); + }) : $('select[name="filetag"]'); $.prepend($('.move > span', QR.el), QR.threadSelector); $.on(QR.threadSelector, 'mousedown', function(e) { return e.stopPropagation(); @@ -2483,7 +2483,9 @@ } QR.abort(); reply = QR.replies[0]; - threadID = g.THREAD_ID || QR.threadSelector.value; + if (!((g.BOARD === 'f') && !g.REPLY)) { + threadID = g.THREAD_ID || QR.threadSelector.value; + } if (threadID === 'new') { if (((_ref = g.BOARD) === 'vg' || _ref === 'q') && !reply.sub) { err = 'New threads require a subject.'; @@ -2544,6 +2546,7 @@ sub: reply.sub, com: reply.com, upfile: reply.file, + filetag: !g.REPLY ? QR.threadSelector.value : void 0, spoiler: reply.spoiler, textonly: textOnly, mode: 'regist', @@ -2591,7 +2594,10 @@ 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." }); - } else if (err = doc.getElementById('errmsg')) { + } else if (err = doc.getElementById('errmsg') || (err = $('center', doc))) { + if ($('font', err)) { + err.textContent = err.textContent.replace(/Return$/, ''); + } if ((_ref = $('a', err)) != null) { _ref.target = '_blank'; } @@ -2599,6 +2605,9 @@ err = 'Connection error with sys.4chan.org.'; } if (err) { + if (err.nodeName === 'CENTER') { + err = err.textContent; + } if (/captcha|verification/i.test(err.textContent) || err === 'Connection error with sys.4chan.org.') { if (/mistyped/i.test(err.textContent)) { err.textContent = 'Error: You seem to have mistyped the CAPTCHA.'; diff --git a/script.coffee b/script.coffee index 8c7c4a5a9..5d69ccc5f 100644 --- a/script.coffee +++ b/script.coffee @@ -1342,7 +1342,12 @@ QR = link = $.el 'h1', innerHTML: "#{if g.REPLY then 'Reply to Thread' else 'Start a Thread'}" $.on link.firstChild, 'click', -> QR.open() - QR.threadSelector.value = 'new' unless g.REPLY + unless g.REPLY + QR.threadSelector.value = + unless g.BOARD is 'f' + 'new' + else + '9999' $('textarea', QR.el).focus() $.before $.id('postForm'), link @@ -1885,9 +1890,13 @@ QR = for thread in $$ '.thread' id = thread.id[1..] threads += "" - QR.threadSelector = $.el 'select' - innerHTML: threads - title: 'Create a new thread / Reply to a thread' + QR.threadSelector = + unless g.BOARD is 'f' + $.el 'select' + innerHTML: threads + title: 'Create a new thread / Reply to a thread' + else + $ 'select[name="filetag"]' $.prepend $('.move > span', QR.el), QR.threadSelector $.on QR.threadSelector, 'mousedown', (e) -> e.stopPropagation() $.on $('#autohide', QR.el), 'change', QR.toggleHide @@ -1933,7 +1942,8 @@ QR = QR.abort() reply = QR.replies[0] - threadID = g.THREAD_ID or QR.threadSelector.value + unless (g.BOARD is 'f') and not g.REPLY + threadID = g.THREAD_ID or QR.threadSelector.value # prevent errors if threadID is 'new' @@ -1994,6 +2004,7 @@ QR = sub: reply.sub com: reply.com upfile: reply.file + filetag: QR.threadSelector.value unless g.REPLY spoiler: reply.spoiler textonly: textOnly mode: 'regist' @@ -2036,12 +2047,16 @@ QR = "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." - else if err = doc.getElementById 'errmsg' # error! + else if err = doc.getElementById('errmsg') or err = $('center', doc) # error! + if $ 'font', err + err.textContent = err.textContent.replace /Return$/, '' $('a', err)?.target = '_blank' # duplicate image link else unless msg = $ 'b', doc err = 'Connection error with sys.4chan.org.' if err + if err.nodeName is 'CENTER' + err = err.textContent if /captcha|verification/i.test(err.textContent) or err is 'Connection error with sys.4chan.org.' # Remove the obnoxious 4chan Pass ad. if /mistyped/i.test err.textContent