From bcc68168b0515f48734de9fcdb7883b06d5947bb Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Thu, 8 Aug 2013 16:32:59 -0700 Subject: [PATCH] Fix Unread.read --- builds/4chan-X.user.js | 24 ++++++++++++++---------- builds/crx/script.js | 24 ++++++++++++++---------- src/Monitoring/Unread.coffee | 22 ++++++++++++---------- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index f1fcb88a2..a0525625e 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -7968,20 +7968,24 @@ i = 0; while (post = posts[i]) { bottom = post.nodes.root.getBoundingClientRect().bottom; - if (bottom > height) { - i++; - continue; - } - ID = post.ID; - if (Conf['Quote Threading']) { - posts.splice(i, 1); - continue; + if (bottom < height) { + ID = post.ID; + if (Conf['Quote Threading']) { + posts.splice(i, 1); + continue; + } } else { - posts.splice(0, i); - break; + if (!Conf['Quote Threading']) { + break; + } } i++; } + if (!Conf['Quote Threading']) { + if (i) { + posts.splice(0, i); + } + } if (!ID) { return; } diff --git a/builds/crx/script.js b/builds/crx/script.js index 2785e07e9..040be83ad 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -7949,20 +7949,24 @@ i = 0; while (post = posts[i]) { bottom = post.nodes.root.getBoundingClientRect().bottom; - if (bottom > height) { - i++; - continue; - } - ID = post.ID; - if (Conf['Quote Threading']) { - posts.splice(i, 1); - continue; + if (bottom < height) { + ID = post.ID; + if (Conf['Quote Threading']) { + posts.splice(i, 1); + continue; + } } else { - posts.splice(0, i); - break; + if (!Conf['Quote Threading']) { + break; + } } i++; } + if (!Conf['Quote Threading']) { + if (i) { + posts.splice(0, i); + } + } if (!ID) { return; } diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 788b41753..4317502b5 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -123,18 +123,20 @@ Unread = while post = posts[i] {bottom} = post.nodes.root.getBoundingClientRect() - if bottom > height # post isnt completely read - i++ - continue - - {ID} = post - if Conf['Quote Threading'] - posts.splice i, 1 - continue + if bottom < height # post is completely read + {ID} = post + if Conf['Quote Threading'] + posts.splice i, 1 + continue else - posts.splice 0, i - break + unless Conf['Quote Threading'] + break i++ + + unless Conf['Quote Threading'] + if i + posts.splice 0, i + return unless ID Unread.lastReadPost = ID if Unread.lastReadPost < ID or !Unread.lastReadPost