diff --git a/4chan_x.user.js b/4chan_x.user.js index 339866d14..5ebabced5 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1392,14 +1392,23 @@ return QR.submit(); }, quote: function(e) { - var i, ss, ta, text, v; + var i, id, qr, s, sel, ss, ta, text, v, _ref; e.preventDefault(); - text = ">>" + this.textContent + "\n"; - if (!QR.qr) { + id = this.textContent; + text = ">>" + id + "\n"; + sel = getSelection(); + if (id === ((_ref = $.x('preceding::input[@type="checkbox"][1]', sel.anchorNode)) != null ? _ref.name : void 0)) { + if (s = sel.toString().replace(/\n/g, '\n>')) { + text += ">" + s + "\n"; + } + } + qr = QR.qr; + if (!qr) { QR.dialog(text); return; } - ta = $('textarea', QR.qr); + $('#autohide', qr).checked = false; + ta = $('textarea', qr); v = ta.value; ss = ta.selectionStart; ta.value = v.slice(0, ss) + text + v.slice(ss); diff --git a/script.coffee b/script.coffee index e0bae4fcc..d58d1a4e6 100644 --- a/script.coffee +++ b/script.coffee @@ -1096,11 +1096,18 @@ QR = QR.submit() #derpy, but prevents calling QR.hasContent twice quote: (e) -> e.preventDefault() - text = ">>#{@textContent}\n" - if not QR.qr + id = @textContent + text = ">>#{id}\n" + sel = getSelection() + if id == $.x('preceding::input[@type="checkbox"][1]', sel.anchorNode)?.name + if s = sel.toString().replace /\n/g, '\n>' + text += ">#{s}\n" + {qr} = QR + if not qr QR.dialog text return - ta = $ 'textarea', QR.qr + $('#autohide', qr).checked = false + ta = $ 'textarea', qr v = ta.value ss = ta.selectionStart ta.value = v[0...ss] + text + v[ss..]