feat: add hn goPage bindings
This commit is contained in:
parent
b53c06cafc
commit
7a1b5bcee9
23
actions.js
23
actions.js
|
@ -296,6 +296,29 @@ actions.hn.collapseNextComment = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actions.hn.goPage = (dist = 1) => {
|
||||||
|
let u
|
||||||
|
try {
|
||||||
|
u = new URL(util.getCurrentLocation())
|
||||||
|
} catch (e) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let page = u.searchParams.get("p")
|
||||||
|
if (page === null || page === "") {
|
||||||
|
page = "1"
|
||||||
|
}
|
||||||
|
const cur = parseInt(page, 10)
|
||||||
|
if (Number.isNaN(cur)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const dest = cur + dist
|
||||||
|
if (dest < 1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
u.searchParams.set("p", dest)
|
||||||
|
actions.openLink(u.href)()
|
||||||
|
}
|
||||||
|
|
||||||
// ProductHunt
|
// ProductHunt
|
||||||
// -----------
|
// -----------
|
||||||
actions.ph = {}
|
actions.ph = {}
|
||||||
|
|
12
keys.js
12
keys.js
|
@ -386,6 +386,18 @@ const maps = {
|
||||||
description: "Go to parent",
|
description: "Go to parent",
|
||||||
callback: actions.hn.goParent,
|
callback: actions.hn.goParent,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
leader: "",
|
||||||
|
alias: "]]",
|
||||||
|
description: "Next page",
|
||||||
|
callback: () => actions.hn.goPage(1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
leader: "",
|
||||||
|
alias: "[[",
|
||||||
|
description: "Prev page",
|
||||||
|
callback: () => actions.hn.goPage(-1),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
"producthunt.com": [
|
"producthunt.com": [
|
||||||
|
|
Loading…
Reference in New Issue