From 8514eae04661e7d3ef1b6c7393e64e95380898d4 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 11 Mar 2012 05:13:04 +0100 Subject: [PATCH] Links in a locationless document have their hash, and probably more, values empty. Also shave some lines. --- 4chan_x.user.js | 20 ++++++++------------ script.coffee | 14 +++++--------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index b09bcb83a..4d3d908b8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -744,6 +744,7 @@ doc = d.implementation.createHTMLDocument(); doc.documentElement.innerHTML = req.responseText; bq = threadID === replyID ? $('blockquote', doc) : $('blockquote', doc.getElementById(replyID)); + $.replace(a.parentNode.parentNode, bq); quotes = $$('.quotelink', bq); for (_i = 0, _len = quotes.length; _i < _len; _i++) { quote = quotes[_i]; @@ -751,7 +752,6 @@ quote.pathname = "/" + g.BOARD + "/res/" + threadID; } } - $.replace(a.parentNode.parentNode, bq); post = { threadId: threadID, quotes: quotes, @@ -2559,7 +2559,7 @@ }; }, update: function() { - var body, id, newPosts, nodes, reply, scroll, _i, _len, _ref, _ref2; + var body, id, newPosts, nodes, reply, scroll, _i, _len, _ref; if (this.status === 404) { Updater.timer.textContent = ''; Updater.count.textContent = 404; @@ -2598,23 +2598,19 @@ body = $.el('body', { innerHTML: this.responseText }); - id = ((_ref = $('td[id]', Updater.br.previousElementSibling)) != null ? _ref.id : void 0) || 0; + id = $('input', Updater.br.previousElementSibling).name; nodes = []; - _ref2 = $$('.reply', body).reverse(); - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - reply = _ref2[_i]; + _ref = $$('.reply', body).reverse(); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + reply = _ref[_i]; if (reply.id <= id) break; nodes.push(reply.parentNode.parentNode.parentNode); } newPosts = nodes.length; scroll = conf['Scrolling'] && Updater.scrollBG() && newPosts && Updater.br.previousElementSibling.getBoundingClientRect().bottom - d.body.clientHeight < 25; if (conf['Verbose']) { - Updater.count.textContent = '+' + newPosts; - if (newPosts === 0) { - Updater.count.className = null; - } else { - Updater.count.className = 'new'; - } + Updater.count.textContent = "+" + newPosts; + Updater.count.className = newPosts ? 'new' : null; } $.before(Updater.br, nodes.reverse()); if (scroll) return Updater.br.previousSibling.scrollIntoView(); diff --git a/script.coffee b/script.coffee index dbf281d2c..bfedb48e7 100644 --- a/script.coffee +++ b/script.coffee @@ -645,11 +645,11 @@ ExpandComment = $ 'blockquote', doc else $ 'blockquote', doc.getElementById replyID + $.replace a.parentNode.parentNode, bq quotes = $$ '.quotelink', bq for quote in quotes if quote.getAttribute('href') is quote.hash quote.pathname = "/#{g.BOARD}/res/#{threadID}" - $.replace a.parentNode.parentNode, bq post = threadId: threadID quotes: quotes @@ -2198,22 +2198,18 @@ Updater = body = $.el 'body', innerHTML: @responseText - id = $('td[id]', Updater.br.previousElementSibling)?.id or 0 + id = $('input', Updater.br.previousElementSibling).name nodes = [] for reply in $$('.reply', body).reverse() - if reply.id <= id #make sure to not insert older posts - break + break if reply.id <= id #make sure to not insert older posts nodes.push reply.parentNode.parentNode.parentNode #table newPosts = nodes.length scroll = conf['Scrolling'] && Updater.scrollBG() && newPosts && Updater.br.previousElementSibling.getBoundingClientRect().bottom - d.body.clientHeight < 25 if conf['Verbose'] - Updater.count.textContent = '+' + newPosts - if newPosts is 0 - Updater.count.className = null - else - Updater.count.className = 'new' + Updater.count.textContent = "+#{newPosts}" + Updater.count.className = if newPosts then 'new' else null $.before Updater.br, nodes.reverse() if scroll