diff --git a/4chan_x.user.js b/4chan_x.user.js index 7917a4566..8ccc92849 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1786,8 +1786,7 @@ var el, id, inline, pathname, root, table, threadID; e.preventDefault(); id = this.hash.slice(1); - root = $.x('ancestor::td[1]', this); - if (table = $("#i" + id, root)) { + if (table = $("#i" + id, $.x('ancestor::td[1]', this))) { $.rm(table); $.removeClass(this, 'inlined'); if (this.className === 'backlink') { @@ -1795,13 +1794,14 @@ } return; } + root = this.parentNode.nodeName === 'FONT' ? this.parentNode : this.nextSibling; if (el = d.getElementById(id)) { inline = quoteInline.table(id, el.innerHTML); if (this.className === 'backlink') { $.after(this.parentNode, inline); $.hide($.x('ancestor::table[1]', el)); } else { - $.after(this.parentNode, inline); + $.after(root, inline); } } else { inline = $.el('td', { @@ -1809,7 +1809,7 @@ id: "i" + id, innerHTML: "Loading " + id + "..." }); - $.after(this.parentNode, inline); + $.after(root, inline); pathname = this.pathname; threadID = pathname.split('/').pop(); $.cache(pathname, (function() { diff --git a/script.coffee b/script.coffee index 22e2acc63..df86712a6 100644 --- a/script.coffee +++ b/script.coffee @@ -1418,26 +1418,26 @@ quoteInline = toggle: (e) -> e.preventDefault() id = @hash[1..] - root = $.x 'ancestor::td[1]', @ - if table = $ "#i#{id}", root + if table = $ "#i#{id}", $.x 'ancestor::td[1]', @ $.rm table $.removeClass @, 'inlined' if @className is 'backlink' $.show $.x 'ancestor::table[1]', d.getElementById id return + root = if @parentNode.nodeName is 'FONT' then @parentNode else @nextSibling if el = d.getElementById id inline = quoteInline.table id, el.innerHTML if @className is 'backlink' $.after @parentNode, inline $.hide $.x 'ancestor::table[1]', el else - $.after @parentNode, inline + $.after root, inline else inline = $.el 'td', className: 'reply inline' id: "i#{id}" innerHTML: "Loading #{id}..." - $.after @parentNode, inline + $.after root, inline {pathname} = @ threadID = pathname.split('/').pop() $.cache pathname, (-> quoteInline.parse @, pathname, id, threadID, inline)