feat(keys): add hn action to open link & comments

This commit is contained in:
Maddison Hellstrom 2019-03-10 10:22:12 -07:00
parent d649f71c02
commit be1edbff68
3 changed files with 10 additions and 3 deletions

View File

@ -97,7 +97,7 @@ sites have been included which can help you perform some common actions:
<tr><td><code>&lt;Space&gt;s</code></td><td>Upvote</td></tr>
<tr><td><code>&lt;Space&gt;S</code></td><td>Downvote</td></tr>
<tr><td><code>&lt;Space&gt;a</code></td><td>View post (link)</td></tr>
<tr><td><code>&lt;Space&gt;A</code></td><td>View post (link) (new tab)</td></tr>
<tr><td><code>&lt;Space&gt;A</code></td><td>View post (link and comments)</td></tr>
<tr><td><code>&lt;Space&gt;c</code></td><td>View post (comments)</td></tr>
<tr><td><code>&lt;Space&gt;C</code></td><td>View post (comments) (new tab)</td></tr>
<tr><td><code>gp</code></td><td>Go to parent</td></tr>

View File

@ -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 = {}

View File

@ -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",