Permalink
Browse files

Fixed some bugs in Hacker News comment voting.

  • Loading branch information...
1 parent 5ee11ab commit 5870e12a11b6e293f32a8fc386f69e9184813320 @jeresig committed Sep 4, 2008
Showing with 7 additions and 3 deletions.
  1. +7 −3 vote.js
View
10 vote.js
@@ -135,7 +135,9 @@ CmdUtils.CreateCommand({
});
var comments = jQuery( "span.comment", context.focusedWindow.document ).filter(function(){
- return match.test( jQuery(this).parent().find("a")[0].textContent + ": " + this.textContent );
+ var link = jQuery(this).parent().find("a")[0];
+ return link && jQuery(this).parent().prev(":has(a)").length &&
+ match.test(link.textContent + ": " + this.textContent);
}).parent();
links = links.add( comments );
@@ -216,7 +218,9 @@ CmdUtils.CreateCommand({
});
var comments = jQuery( "span.comment", context.focusedWindow.document ).map(function(){
- return jQuery(this).parent().find("a")[0].textContent + ": " + this.textContent;
+ var link = jQuery(this).parent().find("a")[0];
+ if ( link && jQuery(this).parent().prev(":has(a)").length )
+ return link.textContent + ": " + this.textContent;
}).filter(function(){
return match.test( this );
});
@@ -263,4 +267,4 @@ CmdUtils.CreateCommand({
}
});
-})();
+})();

0 comments on commit 5870e12

Please sign in to comment.