From e394344f3eafdc8c19ebffc5d5096cbf9bcad80f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 3 Mar 2012 20:08:12 +0100 Subject: [PATCH] Node preparsing related fixes in comment expanding. --- 4chan_x.user.js | 23 ++++++++++++++--------- script.coffee | 17 +++++++++++------ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 266314974..eb8922305 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -735,7 +735,7 @@ })); }, parse: function(req, a, threadID, replyID) { - var body, bq, quote, reply, _i, _j, _len, _len2, _ref, _ref2; + var body, bq, post, quote, quotes, reply, _i, _j, _len, _len2, _ref; if (req.status !== 200) { a.textContent = "" + req.status + " " + req.statusText; return; @@ -755,18 +755,23 @@ } } } - _ref2 = $$('.quotelink', bq); - for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { - quote = _ref2[_j]; + quotes = $$('.quotelink', bq); + for (_j = 0, _len2 = quotes.length; _j < _len2; _j++) { + quote = quotes[_j]; if (quote.getAttribute('href') === quote.hash) { quote.pathname = "/" + g.BOARD + "/res/" + threadID; } } - $.replace(a.parentNode.parentNode, bq); - if (conf['Quote Preview']) quotePreview.node(bq); - if (conf['Quote Inline']) quoteInline.node(bq); - if (conf['Indicate OP quote']) quoteOP.node(bq); - if (conf['Indicate Cross-thread Quotes']) return quoteCT.node(bq); + $.replace($.x('ancestor::blockquote', a), bq); + post = { + threadId: threadID, + quotes: quotes, + backlinks: [] + }; + if (conf['Quote Preview']) quotePreview.node(post); + if (conf['Quote Inline']) quoteInline.node(post); + if (conf['Indicate OP quote']) quoteOP.node(post); + if (conf['Indicate Cross-thread Quotes']) return quoteCT.node(post); } }; diff --git a/script.coffee b/script.coffee index 189db43bf..91a55df1f 100644 --- a/script.coffee +++ b/script.coffee @@ -641,18 +641,23 @@ expandComment = if reply.id == replyID bq = $ 'blockquote', reply break - for quote in $$ '.quotelink', bq + quotes = $$ '.quotelink', bq + for quote in quotes if quote.getAttribute('href') is quote.hash quote.pathname = "/#{g.BOARD}/res/#{threadID}" - $.replace a.parentNode.parentNode, bq + $.replace $.x('ancestor::blockquote', a), bq + post = + threadId: threadID + quotes: quotes + backlinks: [] if conf['Quote Preview'] - quotePreview.node bq + quotePreview.node post if conf['Quote Inline'] - quoteInline.node bq + quoteInline.node post if conf['Indicate OP quote'] - quoteOP.node bq + quoteOP.node post if conf['Indicate Cross-thread Quotes'] - quoteCT.node bq + quoteCT.node post expandThread = init: ->