From 52687b5ea6c957eeeb431502c7a35d8044c1cbfa Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 29 Apr 2012 15:39:12 +0200 Subject: [PATCH] Quote Backlinks fixes. --- 4chan_x.user.js | 15 ++++++--------- script.coffee | 13 +++++-------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ab54d6346..3ad45d0b4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3058,7 +3058,7 @@ return Main.callbacks.push(this.node); }, node: function(post) { - var a, container, el, link, qid, quote, quotes, root, _i, _len, _ref; + var a, container, el, link, qid, quote, quotes, _i, _len, _ref; if (post.isInlined) { return; } @@ -3066,17 +3066,17 @@ _ref = post.quotes; for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; - if (qid = quote.hash.slice(1)) { + if (qid = quote.hash.slice(2)) { quotes[qid] = true; } } a = $.el('a', { - href: "#" + post.id, + href: "#p" + post.id, className: post.root.hidden ? 'filtered backlink' : 'backlink', textContent: QuoteBacklink.funk(post.id) }); for (qid in quotes) { - if (!(el = $.id(qid)) || el.className === 'op' && !Conf['OP Backlinks']) { + if (!(el = $.id("pi" + qid)) || /\bop\b/.test(el.parentNode.className) && !Conf['OP Backlinks']) { continue; } link = a.cloneNode(true); @@ -3092,12 +3092,9 @@ container = $.el('span', { className: 'container' }); - $.add(container, [$.tn(' '), link]); - root = $('.reportbutton', el) || $('span[id]', el); - $.after(root, container); - } else { - $.add(container, [$.tn(' '), link]); + $.add(el, container); } + $.add(container, [$.tn(' '), link]); } } }; diff --git a/script.coffee b/script.coffee index 829cfc422..ae58701ef 100644 --- a/script.coffee +++ b/script.coffee @@ -2391,16 +2391,16 @@ QuoteBacklink = quotes = {} for quote in post.quotes # Don't process >>>/b/. - if qid = quote.hash[1..] + if qid = quote.hash[2..] # Duplicate quotes get overwritten. quotes[qid] = true a = $.el 'a', - href: "##{post.id}" + href: "#p#{post.id}" className: if post.root.hidden then 'filtered backlink' else 'backlink' textContent: QuoteBacklink.funk post.id for qid of quotes # Don't backlink the OP. - continue if !(el = $.id qid) or el.className is 'op' and !Conf['OP Backlinks'] + continue if !(el = $.id "pi#{qid}") or /\bop\b/.test(el.parentNode.className) and !Conf['OP Backlinks'] link = a.cloneNode true if Conf['Quote Preview'] $.on link, 'mouseover', QuotePreview.mouseover @@ -2410,11 +2410,8 @@ QuoteBacklink = link.setAttribute 'onclick', "replyhl('#{post.id}');" unless (container = $ '.container', el) and container.parentNode is el container = $.el 'span', className: 'container' - $.add container, [$.tn(' '), link] - root = $('.reportbutton', el) or $('span[id]', el) - $.after root, container - else - $.add container, [$.tn(' '), link] + $.add el, container + $.add container, [$.tn(' '), link] return QuoteInline =