From eca5a9a58a02f957ae4720b9276a629d95fc306b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 19 Jun 2012 14:03:47 +0200 Subject: [PATCH] Backlinks can now be retrieved even if the post's not on the page. Don't remove OP backlinks after unexpending a thread. --- 4chan_x.user.js | 11 ++--------- script.coffee | 5 ++--- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7f6bab429..b58b878f4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -834,7 +834,7 @@ return _results; }, toggle: function(thread) { - var a, backlink, num, pathname, replies, reply, _i, _j, _len, _len1, _ref; + var a, num, pathname, replies, reply, _i, _len; pathname = "/" + g.BOARD + "/res/" + thread.id.slice(1); a = $('.summary', thread); switch (a.textContent[0]) { @@ -867,13 +867,6 @@ reply = replies[_i]; $.rm(reply); } - _ref = $$('.backlink', a.previousElementSibling); - for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { - backlink = _ref[_j]; - if (!$.id(backlink.hash.slice(1))) { - $.rm(backlink); - } - } } }, parse: function(req, thread, a) { @@ -3366,7 +3359,7 @@ } } a = $.el('a', { - href: "#p" + post.ID, + href: "/" + g.BOARD + "/res/" + post.threadID + "#p" + post.ID, className: post.el.hidden ? 'filtered backlink' : 'backlink', textContent: QuoteBacklink.funk(post.ID) }); diff --git a/script.coffee b/script.coffee index 10f1cddfa..442e845cd 100644 --- a/script.coffee +++ b/script.coffee @@ -665,8 +665,6 @@ ExpandThread = replies.splice replies.length - num, num for reply in replies $.rm reply - for backlink in $$ '.backlink', a.previousElementSibling - $.rm backlink unless $.id backlink.hash[1..] return parse: (req, thread, a) -> @@ -697,6 +695,7 @@ ExpandThread = for post in $$ '.summary ~ .replyContainer', a.parentNode $.rm post for backlink in $$ '.backlink', a.previousElementSibling + # Keep backlinks from other threads. $.rm backlink unless $.id backlink.hash[1..] $.after a, nodes @@ -2625,7 +2624,7 @@ QuoteBacklink = # Duplicate quotes get overwritten. quotes[qid] = true a = $.el 'a', - href: "#p#{post.ID}" + href: "/#{g.BOARD}/res/#{post.threadID}#p#{post.ID}" className: if post.el.hidden then 'filtered backlink' else 'backlink' textContent: QuoteBacklink.funk post.ID for qid of quotes