From 4d23ab6b5bab45797b066e19c5fe9107e2068427 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 10 Feb 2012 22:21:38 +0100 Subject: [PATCH] Fix #87 --- 4chan_x.user.js | 12 ++++++++---- script.coffee | 12 +++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index b371b8366..0cf4a9690 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2844,7 +2844,7 @@ return this.classList.toggle('inlined'); }, add: function(q, id) { - var el, i, inline, pathname, root, threadID; + var el, i, inline, pathname, root, table, threadID; root = q.parentNode.nodeName === 'FONT' ? q.parentNode : q.nextSibling ? q.nextSibling : q; if (el = $.id(id)) { inline = quoteInline.table(id, el.innerHTML); @@ -2855,7 +2855,9 @@ if (/\bbacklink\b/.test(q.className)) { $.after(q.parentNode, inline); if (conf['Forward Hiding']) { - $.addClass($.x('ancestor::table', el), 'forwarded'); + table = $.x('ancestor::table', el); + $.addClass(table, 'forwarded'); + ++table.title || (table.title = 1); } return; } @@ -2882,10 +2884,12 @@ _ref = $$('.backlink.inlined', table); for (_i = 0, _len = _ref.length; _i < _len; _i++) { inlined = _ref[_i]; - $.removeClass($.x('ancestor::table', $.id(inlined.hash.slice(1))), 'forwarded'); + table = $.x('ancestor::table', $.id(inlined.hash.slice(1))); + if (!--table.title) $.removeClass(table, 'forwarded'); } if (/\bbacklink\b/.test(q.className)) { - return $.removeClass($.x('ancestor::table', $.id(id)), 'forwarded'); + table = $.x('ancestor::table', $.id(id)); + if (!--table.title) return $.removeClass(table, 'forwarded'); } }, parse: function(req, pathname, id, threadID, inline) { diff --git a/script.coffee b/script.coffee index 79a36d02c..f842c95e2 100644 --- a/script.coffee +++ b/script.coffee @@ -2251,7 +2251,11 @@ quoteInline = unread.update() if /\bbacklink\b/.test q.className $.after q.parentNode, inline - $.addClass $.x('ancestor::table', el), 'forwarded' if conf['Forward Hiding'] + if conf['Forward Hiding'] + table = $.x 'ancestor::table', el + $.addClass table, 'forwarded' + # Will only unhide if there's no inlined backlinks of it anymore. + ++table.title or table.title = 1 return $.after root, inline else @@ -2270,9 +2274,11 @@ quoteInline = $.rm table return unless conf['Forward Hiding'] for inlined in $$ '.backlink.inlined', table - $.removeClass $.x('ancestor::table', $.id inlined.hash[1..]), 'forwarded' + table = $.x 'ancestor::table', $.id inlined.hash[1..] + $.removeClass table, 'forwarded' unless --table.title if /\bbacklink\b/.test q.className - $.removeClass $.x('ancestor::table', $.id id), 'forwarded' + table = $.x 'ancestor::table', $.id id + $.removeClass table, 'forwarded' unless --table.title parse: (req, pathname, id, threadID, inline) -> return unless inline.parentNode