diff --git a/4chan_x.user.js b/4chan_x.user.js index 381d1852e..b6ea9ad0d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1868,9 +1868,9 @@ id = this.previousSibling.hash.slice(2); text = ">>" + id + "\n"; sel = window.getSelection(); - if ((s = sel.toString()) && id === ((_ref = $.x('ancestor-or-self::blockquote', sel.anchorNode)) != null ? _ref.id.match(/\d+$/)[0] : void 0)) { + if ((s = sel.toString().trim()) && id === ((_ref = $.x('ancestor-or-self::blockquote', sel.anchorNode)) != null ? _ref.id.match(/\d+$/)[0] : void 0)) { if ($.engine === 'presto') { - s = d.getSelection(); + s = d.getSelection().trim(); } s = s.replace(/\n/g, '\n>'); text += ">" + s + "\n"; diff --git a/script.coffee b/script.coffee index 6944b3de9..c2d415bf3 100644 --- a/script.coffee +++ b/script.coffee @@ -1434,9 +1434,9 @@ QR = text = ">>#{id}\n" sel = window.getSelection() - if (s = sel.toString()) and id is $.x('ancestor-or-self::blockquote', sel.anchorNode)?.id.match(/\d+$/)[0] + if (s = sel.toString().trim()) and id is $.x('ancestor-or-self::blockquote', sel.anchorNode)?.id.match(/\d+$/)[0] # XXX Opera needs d.getSelection() to retain linebreaks from the selected text - s = d.getSelection() if $.engine is 'presto' + s = d.getSelection().trim() if $.engine is 'presto' s = s.replace /\n/g, '\n>' text += ">#{s}\n"