Skip to content

Commit

Permalink
Only open two windows if the article and comments are not the same link
Browse files Browse the repository at this point in the history
  • Loading branch information
erik-h committed Apr 15, 2018
1 parent 6949f14 commit 285936f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions hn-enhance.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,24 @@
// the article and comments links
function buildMultiLink(article, comments) {
var linkAndComment = document.createElement("a");
linkAndComment.appendChild(document.createTextNode("Link + Comments"));

var linkCommentText;
if (article !== comments) {
linkCommentText = "Link + Comments";
}
else {
linkCommentText = "Link = Comments";
}

linkAndComment.appendChild(document.createTextNode(linkCommentText));
linkAndComment.addEventListener("click", function(e) {
e.preventDefault();
window.open(comments);
window.open(article);
if (article !== comments) {
// We only want to open the article if it's not the same
// page as the comments
window.open(article);
}
});

// Use a wrapper span so we get a nice little pipe before the anchor
Expand Down

0 comments on commit 285936f

Please sign in to comment.