diff --git a/README.md b/README.md index 7c77cc9..fe55f60 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ sites have been included which can help you perform some common actions: <Space>sUpvote <Space>SDownvote <Space>aView post (link) -<Space>AView post (link) (new tab) +<Space>AView post (link and comments) <Space>cView post (comments) <Space>CView post (comments) (new tab) gpGo to parent diff --git a/actions.js b/actions.js index 7b2e6e1..4f69552 100644 --- a/actions.js +++ b/actions.js @@ -335,6 +335,13 @@ actions.hn.goPage = (dist = 1) => { actions.openLink(u.href)() } +actions.hn.openLinkAndComments = (e) => { + const linkUrl = e.querySelector("a.storylink").href + const commentsUrl = e.nextElementSibling.querySelector("td > a[href*='item']:not(.storylink)").href + actions.openLink(commentsUrl, { newTab: true })() + actions.openLink(linkUrl, { newTab: true })() +} + // ProductHunt // ----------- actions.ph = {} diff --git a/keys.js b/keys.js index c51a239..36ec87a 100644 --- a/keys.js +++ b/keys.js @@ -390,8 +390,8 @@ const maps = { }, { alias: "A", - description: "View post (link) (new tab)", - callback: actions.createHint(".storylink", actions.openAnchor({ newTab: true })), + description: "View post (link and comments)", + callback: actions.createHint(".athing", actions.hn.openLinkAndComments), }, { alias: "c",