From ccc6e009de9fd0fc53f326834b7b4e35d21857cd Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Dec 2011 23:22:59 +0100 Subject: [PATCH] Decrease the unread count when inlining unread posts. Close #57 --- 4chan_x.user.js | 7 ++++++- changelog | 1 + script.coffee | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 539b321a0..85127f929 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2469,10 +2469,15 @@ return this.classList.toggle('inlined'); }, add: function(q, id) { - var el, inline, pathname, root, threadID; + var el, i, inline, pathname, root, threadID; root = q.parentNode.nodeName === 'FONT' ? q.parentNode : q.nextSibling ? q.nextSibling : q; if (el = $.id(id)) { inline = quoteInline.table(id, el.innerHTML); + if (g.REPLY && conf['Unread Count'] && (i = unread.replies.indexOf(el.parentNode.parentNode.parentNode)) !== -1) { + unread.replies.splice(i, 1); + unread.updateTitle(); + Favicon.update(); + } if (/\bbacklink\b/.test(q.className)) { $.after(q.parentNode, inline); if (conf['Forward Hiding']) { diff --git a/changelog b/changelog index dc57939e7..514b910c4 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,7 @@ master - mayhem redirect 404'd pictures to archives when possible + the unread count will decrease when inlining quotes of unread posts the report button can open multiple popups again add omploader to the list of optional flavors (http://ompldr.org/upload?url1=) update archive redirections diff --git a/script.coffee b/script.coffee index 0999439f6..cdce5bfbf 100644 --- a/script.coffee +++ b/script.coffee @@ -1959,6 +1959,10 @@ quoteInline = root = if q.parentNode.nodeName is 'FONT' then q.parentNode else if q.nextSibling then q.nextSibling else q if el = $.id id inline = quoteInline.table id, el.innerHTML + if g.REPLY and conf['Unread Count'] and (i = unread.replies.indexOf el.parentNode.parentNode.parentNode) isnt -1 + unread.replies.splice i, 1 + unread.updateTitle() + Favicon.update() if /\bbacklink\b/.test q.className $.after q.parentNode, inline $.addClass $.x('ancestor::table', el), 'forwarded' if conf['Forward Hiding']