From b2792a05f97f1db878991c795dbe52aae4df4138 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 18 Mar 2012 01:21:45 +0100 Subject: [PATCH] Fix cross-thread quotes after expanding the comment. --- 4chan_x.user.js | 8 +++++--- script.coffee | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1c9089fba..a8d8ac40b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -735,7 +735,7 @@ })); }, parse: function(req, a, threadID, replyID) { - var doc, node, post, quote, quotes, _i, _len; + var doc, href, node, post, quote, quotes, _i, _len; if (req.status !== 200) { a.textContent = "" + req.status + " " + req.statusText; return; @@ -747,8 +747,10 @@ quotes = node.getElementsByClassName('quotelink'); for (_i = 0, _len = quotes.length; _i < _len; _i++) { quote = quotes[_i]; - if (quote.hash === quote.getAttribute('href')) { + if (quote.hash === (href = quote.getAttribute('href'))) { quote.pathname = "/" + g.BOARD + "/res/" + threadID; + } else if (href !== quote.href) { + quote.href = "res/" + href; } } post = { @@ -853,7 +855,7 @@ _ref2 = $$('.quotelink', table); for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { quote = _ref2[_j]; - if ((href = quote.getAttribute('href')) === quote.hash) { + if (quote.hash === (href = quote.getAttribute('href'))) { quote.pathname = pathname; } else if (href !== quote.href) { quote.href = "res/" + href; diff --git a/script.coffee b/script.coffee index f295c56d8..244ba74a8 100644 --- a/script.coffee +++ b/script.coffee @@ -646,8 +646,10 @@ ExpandComment = quotes = node.getElementsByClassName 'quotelink' for quote in quotes - if quote.hash is quote.getAttribute 'href' + if quote.hash is href = quote.getAttribute 'href' # Add pathname to in-thread quotes quote.pathname = "/#{g.BOARD}/res/#{threadID}" + else if href isnt quote.href # Fix cross-thread links, not cross-board ones + quote.href = "res/#{href}" post = el: node threadId: threadID @@ -726,9 +728,9 @@ ExpandThread = for reply in $$ '.reply', doc table = d.importNode reply.parentNode.parentNode.parentNode for quote in $$ '.quotelink', table - if (href = quote.getAttribute 'href') is quote.hash #add pathname to normal quotes + if quote.hash is href = quote.getAttribute 'href' # Add pathname to in-thread quotes quote.pathname = pathname - else if href isnt quote.href #fix x-thread links, not x-board ones + else if href isnt quote.href # Fix cross-thread links, not cross-board ones quote.href = "res/#{href}" link = $ '.quotejs', table link.href = "res/#{thread.firstChild.id}##{reply.id}"