diff --git a/4chan_x.js b/4chan_x.js index cdbe68a91..6237b8a0e 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1693,25 +1693,19 @@ return g.callbacks.push(quoteBacklink.node); }, node: function(root) { - var backlink, el, good, id, link, quote, _i, _j, _len, _len2, _ref, _ref2, _results; + var el, id, link, qid, quote, quotes, _i, _len, _ref, _results; id = $('td[id]', root).id; + quotes = {}; _ref = $$('a.quotelink', root); - _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; - if (!(el = d.getElementById(quote.textContent.slice(2)))) { - continue; - } - good = 1; - _ref2 = $$('a.backlink', el); - for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { - backlink = _ref2[_j]; - if (backlink.textContent === '>>' + id) { - good = 0; - break; - } - } - if (!good) { + qid = quote.textContent.slice(2); + quotes[qid] = quote; + } + _results = []; + for (qid in quotes) { + quote = quotes[qid]; + if (!(el = d.getElementById(qid))) { continue; } link = $.el('a', { diff --git a/script.coffee b/script.coffee index 4fdf39755..dfb2cf7a2 100644 --- a/script.coffee +++ b/script.coffee @@ -1352,14 +1352,13 @@ quoteBacklink = g.callbacks.push quoteBacklink.node node: (root) -> {id} = $ 'td[id]', root + quotes = {} for quote in $$ 'a.quotelink', root - continue unless el = d.getElementById quote.textContent[2..] - good = 1 - for backlink in $$ 'a.backlink', el - if backlink.textContent is '>>'+id - good = 0 - break - continue if not good + qid = quote.textContent[2..] #FIXME cross-board links + #duplicate quotes get overwritten + quotes[qid] = quote + for qid, quote of quotes + continue unless el = d.getElementById qid link = $.el 'a', href: '#'+id className: 'backlink'