diff --git a/builds/4chan-X.js b/builds/4chan-X.js index bc18520ef..2a87ce760 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -6351,7 +6351,8 @@ }); }, node: function() { - var ID, post, posts, _ref; + var ID, post, posts, _ref, + _this = this; Unread.thread = this; Unread.title = d.title; @@ -6375,7 +6376,9 @@ $.on(d, 'visibilitychange', Unread.setLine); } if (Conf['Scroll to Last Read Post']) { - return $.on(window, 'load', Unread.scroll); + return $.on(window, 'load', function(posts) { + return Unread.scroll.apply(_this, posts); + }); } }, scroll: function() { @@ -6390,9 +6393,12 @@ break; } } + if (!root) { + return; + } return root.scrollIntoView(false); } else if (posts.length) { - return Header.scrollToPost(posts[posts.length - 1].nodes.root); + return Header.scrollToPost(posts[post.length - 1].nodes.root); } }, sync: function() { diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index bc1aa2a02..c5af5d6cc 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -6342,7 +6342,8 @@ }); }, node: function() { - var ID, post, posts, _ref; + var ID, post, posts, _ref, + _this = this; Unread.thread = this; Unread.title = d.title; @@ -6366,7 +6367,9 @@ $.on(d, 'visibilitychange', Unread.setLine); } if (Conf['Scroll to Last Read Post']) { - return $.on(window, 'load', Unread.scroll); + return $.on(window, 'load', function(posts) { + return Unread.scroll.apply(_this, posts); + }); } }, scroll: function() { @@ -6381,9 +6384,12 @@ break; } } + if (!root) { + return; + } return root.scrollIntoView(false); } else if (posts.length) { - return Header.scrollToPost(posts[posts.length - 1].nodes.root); + return Header.scrollToPost(posts[post.length - 1].nodes.root); } }, sync: function() { diff --git a/builds/crx.crx b/builds/crx.crx index 30b9027aa..847e07949 100644 Binary files a/builds/crx.crx and b/builds/crx.crx differ diff --git a/builds/crx/script.js b/builds/crx/script.js index 7978d4e79..9e2816bd7 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -6265,7 +6265,8 @@ }); }, node: function() { - var ID, post, posts, _ref; + var ID, post, posts, _ref, + _this = this; Unread.thread = this; Unread.title = d.title; @@ -6289,7 +6290,9 @@ $.on(d, 'visibilitychange', Unread.setLine); } if (Conf['Scroll to Last Read Post']) { - return $.on(window, 'load', Unread.scroll); + return $.on(window, 'load', function(posts) { + return Unread.scroll.apply(_this, posts); + }); } }, scroll: function() { @@ -6304,9 +6307,12 @@ break; } } + if (!root) { + return; + } return root.scrollIntoView(false); } else if (posts.length) { - return Header.scrollToPost(posts[posts.length - 1].nodes.root); + return Header.scrollToPost(posts[post.length - 1].nodes.root); } }, sync: function() { diff --git a/src/features/monitoring/unread.coffee b/src/features/monitoring/unread.coffee index 8dd1243bf..18edbd94d 100644 --- a/src/features/monitoring/unread.coffee +++ b/src/features/monitoring/unread.coffee @@ -26,7 +26,9 @@ Unread = $.on d, 'ThreadUpdate', Unread.onUpdate $.on d, 'scroll visibilitychange', Unread.read $.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line'] - $.on window, 'load', Unread.scroll if Conf['Scroll to Last Read Post'] + if Conf['Scroll to Last Read Post'] + $.on window, 'load', (posts) => + Unread.scroll.apply @, posts scroll: -> # Let the header's onload callback handle it. @@ -35,10 +37,11 @@ Unread = # Scroll to before the first unread post. while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root break unless (Get.postFromRoot root).isHidden + return unless root root.scrollIntoView false else if posts.length # Scroll to the last read post. - Header.scrollToPost posts[posts.length - 1].nodes.root + Header.scrollToPost (posts[post.length - 1]).nodes.root sync: -> lastReadPost = Unread.db.get