From 0d136c967ae9da8001fa8bf78637a661b5d2e7da Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 6 Aug 2012 20:41:18 +0200 Subject: [PATCH] Fix error when highlighting and toping an alone thread. --- 4chan_x.user.js | 6 ++++-- script.coffee | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c86c7abf2..88c72d29a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -657,8 +657,10 @@ $.addClass(root, result["class"]); if (isOP && result.top && !g.REPLY) { thisThread = root.parentNode; - if (firstThread = $('div[class="postContainer opContainer"]').parentNode) { - $.before(firstThread, [thisThread, thisThread.nextElementSibling]); + if (firstThread = $('div[class="postContainer opContainer"]')) { + if (firstThread !== root) { + $.before(firstThread.parentNode, [thisThread, thisThread.nextElementSibling]); + } } } } diff --git a/script.coffee b/script.coffee index c06fdcab1..b72a3146d 100644 --- a/script.coffee +++ b/script.coffee @@ -531,8 +531,9 @@ Filter = # Put the highlighted OPs' thread on top of the board page... thisThread = root.parentNode # ...before the first non highlighted thread. - if firstThread = $('div[class="postContainer opContainer"]').parentNode - $.before firstThread, [thisThread, thisThread.nextElementSibling] + if firstThread = $ 'div[class="postContainer opContainer"]' + unless firstThread is root + $.before firstThread.parentNode, [thisThread, thisThread.nextElementSibling] name: (post) -> $('.name', post.el).textContent