diff --git a/4chan_x.user.js b/4chan_x.user.js index 0da2630bd..b09bcb83a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -736,29 +736,17 @@ })); }, parse: function(req, a, threadID, replyID) { - var body, bq, post, quote, quotes, reply, _i, _j, _len, _len2, _ref; + var bq, doc, post, quote, quotes, _i, _len; if (req.status !== 200) { a.textContent = "" + req.status + " " + req.statusText; return; } - body = $.el('body', { - innerHTML: req.responseText - }); - if (threadID === replyID) { - bq = $('blockquote', body); - } else { - _ref = $$('td[id]', body); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - reply = _ref[_i]; - if (reply.id === replyID) { - bq = $('blockquote', reply); - break; - } - } - } + doc = d.implementation.createHTMLDocument(); + doc.documentElement.innerHTML = req.responseText; + bq = threadID === replyID ? $('blockquote', doc) : $('blockquote', doc.getElementById(replyID)); quotes = $$('.quotelink', bq); - for (_j = 0, _len2 = quotes.length; _j < _len2; _j++) { - quote = quotes[_j]; + for (_i = 0, _len = quotes.length; _i < _len; _i++) { + quote = quotes[_i]; if (quote.getAttribute('href') === quote.hash) { quote.pathname = "/" + g.BOARD + "/res/" + threadID; } diff --git a/script.coffee b/script.coffee index 1eb783ebd..dbf281d2c 100644 --- a/script.coffee +++ b/script.coffee @@ -637,18 +637,14 @@ ExpandComment = a.textContent = "#{req.status} #{req.statusText}" return - body = $.el 'body', - innerHTML: req.responseText + doc = d.implementation.createHTMLDocument() + doc.documentElement.innerHTML = req.responseText - if threadID is replyID #OP - bq = $ 'blockquote', body - else - #css selectors don't like ids starting with numbers, - # getElementById only works for root document. - for reply in $$ 'td[id]', body - if reply.id == replyID - bq = $ 'blockquote', reply - break + bq = + if threadID is replyID # OP + $ 'blockquote', doc + else + $ 'blockquote', doc.getElementById replyID quotes = $$ '.quotelink', bq for quote in quotes if quote.getAttribute('href') is quote.hash