From e52ee68c97017b261e3e3d0b3c79d023a162a9cc Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 30 Apr 2012 10:02:40 +0200 Subject: [PATCH] This should fix Comment Expansion. --- 4chan_x.user.js | 11 +++++------ script.coffee | 14 ++++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1bda89a86..a5b3cec7f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -762,18 +762,17 @@ ExpandComment = { init: function() { var a, _i, _len, _ref; - _ref = $$('.abbr > a'); + _ref = $$('.abbr'); for (_i = 0, _len = _ref.length; _i < _len; _i++) { a = _ref[_i]; - $.on(a, 'click', ExpandComment.expand); + $.on(a.firstElementChild, 'click', ExpandComment.expand); } }, expand: function(e) { var a, replyID, threadID, _, _ref; e.preventDefault(); - _ref = this.href.match(/(\d+)#(\d+)/), _ = _ref[0], threadID = _ref[1], replyID = _ref[2]; + _ref = this.href.match(/(\d+)#p(\d+)/), _ = _ref[0], threadID = _ref[1], replyID = _ref[2]; this.textContent = "Loading " + replyID + "..."; - threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]/div', this).id; a = this; return $.cache(this.pathname, (function() { return ExpandComment.parse(this, a, threadID, replyID); @@ -787,7 +786,7 @@ } doc = d.implementation.createHTMLDocument(''); doc.documentElement.innerHTML = req.response; - node = d.importNode(doc.getElementById(replyID)); + node = d.importNode(doc.getElementById("m" + replyID)); quotes = node.getElementsByClassName('quotelink'); for (_i = 0, _len = quotes.length; _i < _len; _i++) { quote = quotes[_i]; @@ -818,7 +817,7 @@ if (Conf['Indicate Cross-thread Quotes']) { QuoteCT.node(post); } - return $.replace(a.parentNode.parentNode, node.lastChild); + return $.replace(a.parentNode.parentNode, node); } }; diff --git a/script.coffee b/script.coffee index 6cf60faa3..e28bbb90e 100644 --- a/script.coffee +++ b/script.coffee @@ -609,14 +609,13 @@ StrikethroughQuotes = ExpandComment = init: -> - for a in $$ '.abbr > a' - $.on a, 'click', ExpandComment.expand + for a in $$ '.abbr' + $.on a.firstElementChild, 'click', ExpandComment.expand return expand: (e) -> e.preventDefault() - [_, threadID, replyID] = @href.match /(\d+)#(\d+)/ + [_, threadID, replyID] = @href.match /(\d+)#p(\d+)/ @textContent = "Loading #{replyID}..." - threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id a = @ $.cache @pathname, (-> ExpandComment.parse @, a, threadID, replyID) parse: (req, a, threadID, replyID) -> @@ -629,12 +628,15 @@ ExpandComment = # Import the node to fix quote.hashes # as they're empty when in a different document. - node = d.importNode doc.getElementById replyID + node = d.importNode doc.getElementById "m#{replyID}" quotes = node.getElementsByClassName 'quotelink' for quote in quotes if quote.hash is href = quote.getAttribute 'href' # Add pathname to in-thread quotes quote.pathname = "/#{g.BOARD}/res/#{threadID}" + # NEW HTML ??? + # OP quotes have different href attribute than normal quotes. + # Waiting for a reply from moot. else if href isnt quote.href # Fix cross-thread links, not cross-board ones quote.href = "res/#{href}" post = @@ -652,7 +654,7 @@ ExpandComment = QuoteOP.node post if Conf['Indicate Cross-thread Quotes'] QuoteCT.node post - $.replace a.parentNode.parentNode, node.lastChild + $.replace a.parentNode.parentNode, node ExpandThread = init: ->