Fix mapsitekeys & youtube mappings

This commit is contained in:
Maddison Hellstrom 2018-07-30 06:15:14 -07:00
parent 05aa243b88
commit 24150ca8ba
1 changed files with 14 additions and 8 deletions

22
conf.js
View File

@ -231,11 +231,17 @@ function mapsitekey(domainRegex, key, desc, f, opts = {}) {
mapkey(`${o.leader}${key}`, desc, f, { domain: domainRegex })
}
function mapsitekeys(d, maps) {
function mapsitekeys(d, maps, opts = {}) {
const domain = d.replace(".", "\\.")
const domainRegex = new RegExp(`^http(s)?://(([a-zA-Z0-9-_]+\\.)*)(${domain})(/.*)?`)
maps.forEach((map) => {
mapsitekey(domainRegex, ...map)
const [
key,
desc,
f,
subOpts = {},
] = map
mapsitekey(domainRegex, key, desc, f, Object.assign({}, opts, subOpts))
})
}
@ -248,12 +254,12 @@ mapsitekeys("yelp.com", [
])
mapsitekeys("youtube.com", [
["a", "Open video", Hint("a[id='video-title']")],
])
mapsitekeys("youtube.com/watch", [
["F", "Toggle fullscreen", ytFullscreen, { leader: "" }],
["<Space>", "Play/pause", Hint(".ytp-play-button"), { leader: "" }],
])
["A", "Open video", Hint("*[id='video-title']")],
["C", "Open channel", Hint("*[id='byline']")],
["gH", "Goto homepage", () => window.location.assign("https://www.youtube.com/feed/subscriptions?flow=2")],
["F", "Toggle fullscreen", ytFullscreen],
["<Space>", "Play/pause", Hint(".ytp-play-button")],
], { leader: "" })
mapsitekeys("vimeo.com", [
["F", "Toggle fullscreen", vimeoFullscreen],