Add check for null/length

This commit is contained in:
Yuya Ochiai
2016-02-13 20:20:56 +09:00
parent fea44a09c2
commit 75bfb119e6

View File

@@ -42,13 +42,18 @@ var unreadCountTimer = setInterval(function() {
// find active post-list.
var postLists = document.querySelectorAll('div.post-list__content');
var post;
if (postLists.length === 0) {
return;
}
var post = null;
for (var i = 0; i < postLists.length; i++) {
if (isElementVisible(postLists[i])) {
post = postLists[i].children[0];
}
}
if (post === null) {
return;
}
// find latest post and save.
while (post = post.nextSibling) {
if (post.nextSibling === null) {