From d294d22d05a7fb72352059b47000494194269c56 Mon Sep 17 00:00:00 2001 From: Tony Onodi <tonyonodi@gmail.com> Date: Sun, 13 Jul 2014 01:51:14 +0100 Subject: [PATCH] Quick fix prevents error for "x is hiring" posts. --- hackernews.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hackernews.js b/hackernews.js index c9a18b9..ac8914c 100644 --- a/hackernews.js +++ b/hackernews.js @@ -12,8 +12,9 @@ function getCommentURL( linkToPost ) { // check if next row was found if( commentRow ) { - commentLink = commentRow.querySelector("a:last-child"), // get the last link in that row - commentURL = commentLink.getAttribute("href"); // get the href attribute of comment link + commentLink = commentRow.querySelector("a:last-child"); // get the last link in that row + if ( commentLink ) + commentURL = commentLink.getAttribute("href"); // get the href attribute of comment link // return comment url return commentURL;