Skip to content

Commit

Permalink
Open article after the HN comments
Browse files Browse the repository at this point in the history
Tree Style Tab will mess up the order of the tabs if both links are
opened immediately. This fix adds a slight delay to being able to read
the article, but preserves my precious tab order...
  • Loading branch information
erik-h committed Apr 15, 2018
1 parent 285936f commit b73b8c8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions hn-enhance.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@
linkAndComment.appendChild(document.createTextNode(linkCommentText));
linkAndComment.addEventListener("click", function(e) {
e.preventDefault();
window.open(comments);
if (article !== comments) {
// We only want to open the article if it's not the same
// page as the comments
window.open(article);
var commentsWindow = window.open(comments);
/*
* Load the article _after_ the comments; this isn't useful unless
* certain extensions are in use such as Tree Style Tab, which
* messes up the tab order if there isn't a delay between opening
* the comments and the article
*/
commentsWindow.onload = function() {
if (article !== comments) {
// We only want to open the article if it's not the same
// page as the comments
window.open(article);
}
}
});

Expand Down

0 comments on commit b73b8c8

Please sign in to comment.