diff --git a/4chan_x.user.js b/4chan_x.user.js index 159ca952a..b2911bd25 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -793,7 +793,7 @@ } for (_l = 0, _len3 = quotelinks.length; _l < _len3; _l++) { quotelink = quotelinks[_l]; - if (+quotelink.hash.slice(2) === this.ID) { + if (Get.postDataFromLink(quotelink).postID === this.ID) { $.add(quotelink, $.tn('\u00A0(Dead)')); } } @@ -1447,12 +1447,12 @@ if (link.host === 'boards.4chan.org') { path = link.pathname.split('/'); board = path[1]; - threadID = path[3]; - postID = link.hash.slice(2); + threadID = +path[3]; + postID = +link.hash.slice(2); } else { board = link.dataset.board; - threadID = ''; - postID = link.dataset.postid; + threadID = +link.dataset.threadid || ''; + postID = +link.dataset.postid; } return { board: board, @@ -1521,7 +1521,7 @@ if (post.no > postID) { if (url = Redirect.post(board, postID)) { $.cache(url, function() { - return Get.parseArchivedPost(this, board, postID, root, context); + return Get.archivedPost(this, board, postID, root, context); }); } else { $.addClass(root, 'warning'); @@ -1580,8 +1580,8 @@ comment = bq.innerHTML.replace(/(^|>)(>[^<$]+)(<|$)/g, '$1$2$3'); threadID = data.thread_num; o = { - postID: postID, - threadID: threadID, + postID: "" + postID, + threadID: "" + threadID, board: board, name: data.name_processed, capcode: (function() { @@ -1667,6 +1667,7 @@ target: '_blank' }); a.setAttribute('data-board', board); + a.setAttribute('data-threadid', post.thread.ID); a.setAttribute('data-postid', ID); } else { a = $.el('a', { @@ -1769,7 +1770,7 @@ } post = g.posts["" + board + "." + postID]; post.rmClone(el.dataset.clone); - inThreadID = $.x('ancestor::div[@class="thread"]', quotelink).id.slice(1); + inThreadID = +$.x('ancestor::div[@class="thread"]', quotelink).id.slice(1); if (Conf['Forward Hiding'] && board === g.BOARD.ID && threadID === inThreadID && $.hasClass(quotelink, 'backlink')) { if (!--post.forwarded) { delete post.forwarded; @@ -1966,7 +1967,7 @@ }); }, node: function() { - var board, op, quote, quotelinks, quotes, thread, _i, _j, _len, _len1, _ref; + var board, op, postID, quote, quotelinks, quotes, thread, _i, _j, _len, _len1, _ref, _ref1; if (this.isClone && this.thread === this.context.thread) { return; } @@ -1987,7 +1988,8 @@ } for (_j = 0, _len1 = quotelinks.length; _j < _len1; _j++) { quote = quotelinks[_j]; - if (("" + (quote.pathname.split('/')[1]) + "." + quote.hash.slice(2)) === op) { + _ref1 = Get.postDataFromLink(quote), board = _ref1.board, postID = _ref1.postID; + if (("" + board + "." + postID) === op) { $.add(quote, $.tn(QuoteOP.text)); } } @@ -2003,7 +2005,7 @@ }); }, node: function() { - var board, path, qBoard, qThread, quote, quotelinks, quotes, thread, _i, _len, _ref; + var board, data, quote, quotelinks, quotes, thread, _i, _len, _ref; if (this.isClone && this.thread === this.context.thread) { return; } @@ -2014,16 +2016,14 @@ _ref = this.isClone ? this.context : this, board = _ref.board, thread = _ref.thread; for (_i = 0, _len = quotelinks.length; _i < _len; _i++) { quote = quotelinks[_i]; - if ($.hasClass(quote, 'deadlink')) { + data = Get.postDataFromLink(quote); + if (data.threadID === '') { continue; } - path = quote.pathname.split('/'); - qBoard = path[1]; - qThread = path[3]; - if (this.isClone && qBoard === this.board.ID && +qThread !== this.thread.ID) { + if (this.isClone) { quote.textContent = quote.textContent.replace(QuoteCT.text, ''); } - if (qBoard === board.ID && +qThread !== thread.ID) { + if (data.board === board.ID && data.threadID !== thread.ID) { $.add(quote, $.tn(QuoteCT.text)); } } diff --git a/script.coffee b/script.coffee index 1e36a8fa1..0e50b2e4c 100644 --- a/script.coffee +++ b/script.coffee @@ -636,7 +636,7 @@ class Post for post in [post].concat post.clones quotelinks.push.apply quotelinks, Array::slice.call post.nodes.backlinks for quotelink in quotelinks - if +quotelink.hash[2..] is @ID + if Get.postDataFromLink(quotelink).postID is @ID $.add quotelink, $.tn '\u00A0(Dead)' return addClone: (context) -> @@ -1395,12 +1395,12 @@ Get = if link.host is 'boards.4chan.org' path = link.pathname.split '/' board = path[1] - threadID = path[3] - postID = link.hash[2..] + threadID = +path[3] + postID = +link.hash[2..] else # resurrected quote board = link.dataset.board - threadID = '' - postID = link.dataset.postid + threadID = +link.dataset.threadid or '' + postID = +link.dataset.postid return { board: board threadID: threadID @@ -1462,7 +1462,7 @@ Get = # The post can be deleted by the time we check a quote. if url = Redirect.post board, postID $.cache url, -> - Get.parseArchivedPost @, board, postID, root, context + Get.archivedPost @, board, postID, root, context else $.addClass root, 'warning' root.textContent = "Post No.#{postID} was not found." @@ -1528,8 +1528,8 @@ Get = threadID = data.thread_num o = # id - postID: postID - threadID: threadID + postID: "#{postID}" + threadID: "#{threadID}" board: board # info name: data.name_processed @@ -1614,8 +1614,9 @@ Quotify = className: 'quotelink deadlink' textContent: "#{quote}\u00A0(Dead)" target: '_blank' - a.setAttribute 'data-board', board - a.setAttribute 'data-postid', ID + a.setAttribute 'data-board', board + a.setAttribute 'data-threadid', post.thread.ID + a.setAttribute 'data-postid', ID else # Don't (Dead) when quotifying in an archived post, # and we know the post still exists. @@ -1717,7 +1718,7 @@ QuoteInline = post = g.posts["#{board}.#{postID}"] post.rmClone el.dataset.clone - inThreadID = $.x('ancestor::div[@class="thread"]', quotelink).id[1..] + inThreadID = +$.x('ancestor::div[@class="thread"]', quotelink).id[1..] # Decrease forward count and unhide. if Conf['Forward Hiding'] and @@ -1896,7 +1897,8 @@ QuoteOP = # add (OP) to quotes quoting this context's OP. return unless -1 < quotes.indexOf op for quote in quotelinks - if "#{quote.pathname.split('/')[1]}.#{quote.hash[2..]}" is op + {board, postID} = Get.postDataFromLink quote + if "#{board}.#{postID}" is op $.add quote, $.tn QuoteOP.text return @@ -1916,13 +1918,11 @@ QuoteCT = {board, thread} = if @isClone then @context else @ for quote in quotelinks - continue if $.hasClass quote, 'deadlink' - path = quote.pathname.split '/' - qBoard = path[1] - qThread = path[3] - if @isClone and qBoard is @board.ID and +qThread isnt @thread.ID + data = Get.postDataFromLink quote + continue if data.threadID is '' # deadlink + if @isClone quote.textContent = quote.textContent.replace QuoteCT.text, '' - if qBoard is board.ID and +qThread isnt thread.ID + if data.board is board.ID and data.threadID isnt thread.ID $.add quote, $.tn QuoteCT.text return