diff --git a/4chan_x.user.js b/4chan_x.user.js index eeb502aa9..7a49a252a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -737,7 +737,7 @@ })); }, parse: function(req, a, threadID, replyID) { - var bq, doc, post, quote, quotes, tmp, _i, _len; + var doc, node, post, quote, quotes, _i, _len; if (req.status !== 200) { a.textContent = "" + req.status + " " + req.statusText; return; @@ -745,10 +745,8 @@ doc = d.implementation.createHTMLDocument(null); doc.documentElement.innerHTML = req.responseText; Threading.op($('body > form', doc).firstChild); - bq = doc.getElementById(replyID).lastChild; - tmp = $.el('div'); - $.add(tmp, bq); - quotes = bq.getElementsByClassName('quotelink'); + node = d.importNode(doc.getElementById(replyID)); + quotes = node.getElementsByClassName('quotelink'); for (_i = 0, _len = quotes.length; _i < _len; _i++) { quote = quotes[_i]; if (quote.hash === quote.getAttribute('href')) { @@ -756,7 +754,7 @@ } } post = { - el: bq.parentNode, + el: node, threadId: threadID, quotes: quotes, backlinks: [] @@ -766,7 +764,7 @@ if (conf['Quote Inline']) QuoteInline.node(post); if (conf['Indicate OP quote']) QuoteOP.node(post); if (conf['Indicate Cross-thread Quotes']) QuoteCT.node(post); - return $.replace(a.parentNode.parentNode, bq); + return $.replace(a.parentNode.parentNode, node.lastChild); } }; diff --git a/script.coffee b/script.coffee index d2a7c283d..eb625ad42 100644 --- a/script.coffee +++ b/script.coffee @@ -642,24 +642,21 @@ ExpandComment = doc.documentElement.innerHTML = req.responseText Threading.op $('body > form', doc).firstChild - bq = doc.getElementById(replyID).lastChild - - # Add the bq in a temporary element to fix quote.hashes + # Import the node to fix quote.hashes # as they're empty when in a different document. - tmp = $.el 'div' - $.add tmp, bq + node = d.importNode doc.getElementById replyID - quotes = bq.getElementsByClassName 'quotelink' + quotes = node.getElementsByClassName 'quotelink' for quote in quotes if quote.hash is quote.getAttribute 'href' quote.pathname = "/#{g.BOARD}/res/#{threadID}" post = - el: bq.parentNode + el: node threadId: threadID quotes: quotes backlinks: [] if conf['Resurrect Quotes'] - Quotify.node post + Quotify.node post if conf['Quote Preview'] QuotePreview.node post if conf['Quote Inline'] @@ -668,7 +665,7 @@ ExpandComment = QuoteOP.node post if conf['Indicate Cross-thread Quotes'] QuoteCT.node post - $.replace a.parentNode.parentNode, bq + $.replace a.parentNode.parentNode, node.lastChild ExpandThread = init: ->