diff --git a/README.md b/README.md
index 2978080..c556106 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ Maddy's SurfingKeys Configuration
This is my personal configuration for the wonderful [SurfingKeys](https://github.com/brookhong/Surfingkeys) browser extension.
Its primary features include [keybindings for performing common actions](#site-specific-key-mappings) on many popular
-sites, as well as OmniBar support for [auto-completing searches](#bundled-search-engine-completions) within 44 sites (and growing)!
+sites, as well as OmniBar support for [auto-completing searches](#bundled-search-engine-completions) within 47 sites (and growing)!
Table of Contents
-----------------
@@ -32,7 +32,7 @@ Features
### Site-Specific Key Mappings
-181 key mappings for 16 unique
+195 key mappings for 17 unique
sites have been included which can help you perform some common actions:
@@ -50,6 +50,8 @@ sites have been included which can help you perform some common actions:
=w | Lookup whois information for domain |
=d | Lookup dns information for domain |
=D | Lookup all information for domain |
+=c | Show Google's cached version of page |
+=a | Show Archive.org Wayback Machine for page |
;pd | Toggle PDF viewer from SurfingKeys |
amazon.com |
---|
Mapping | Description |
<Space>fs | Fakespot |
@@ -73,11 +75,13 @@ sites have been included which can help you perform some common actions:
<Space>u | View User |
<Space>f | View File |
<Space>i | View Issue |
+<Space>p | View Pull Request |
gp | Go to parent |
<Space>s | Toggle Star |
<Space>S | Check Star |
<Space>y | Copy Project Path |
<Space>Y | Copy Project Path (including domain) |
+<Space>l | Toggle repo language stats |
<Space>D | View GoDoc for Project |
gitlab.com |
---|
Mapping | Description |
<Space>s | Toggle Star |
@@ -97,6 +101,8 @@ sites have been included which can help you perform some common actions:
<Space>c | View post (comments) |
<Space>C | View post (comments) (new tab) |
gp | Go to parent |
+]] | Next page |
+[[ | Prev page |
producthunt.com |
---|
Mapping | Description |
<Space>a | View product (external) |
<Space>v | View product |
@@ -124,6 +130,10 @@ sites have been included which can help you perform some common actions:
<Space>F | Toggle fullscreen |
wikipedia.org |
---|
Mapping | Description |
<Space>s | Toggle simple version of current article |
+<Space>a | View page |
+wiktionary.org |
---|
Mapping | Description |
+<Space>s | Toggle simple version of current article |
+<Space>a | View page |
yelp.com |
---|
Mapping | Description |
<Space>fs | Fakespot |
youtube.com |
---|
Mapping | Description |
@@ -138,7 +148,7 @@ sites have been included which can help you perform some common actions:
### Bundled Search Engine Completions
-There are currently 44 Search Engine auto-completions.
+There are currently 47 Search Engine auto-completions.
You can access a Search Engine auto-completion by pressing the search leader key, which is `a` by default, followed by the search engine alias.
@@ -148,6 +158,8 @@ For example, to open the Wikipedia completion, you would type `awp` while in nor
| ----- | ---- | ------ | ----------- |
| `af` | `archforums` | `Google Custom Search` | |
| `al` | `archlinux` | `www.archlinux.org` | |
+ | `as` | `aws` | `google.com` | |
+ | `at` | `alternativeTo` | `alternativeto.net` | |
| `au` | `AUR` | `aur.archlinux.org` | |
| `aw` | `archwiki` | `wiki.archlinux.org` | |
| `az` | `amazon` | `smile.amazon.com` | |
@@ -188,6 +200,7 @@ For example, to open the Wikipedia completion, you would type `awp` while in nor
| `wa` | `wolframalpha` | `www.wolframalpha.com` | [:framed_picture:](#wolframalpha) [:framed_picture:](#wolframalpha-2) |
| `wp` | `wikipedia` | `en.wikipedia.org` | |
| `ws` | `wikipedia-simple` | `simple.wikipedia.org` | |
+ | `wt` | `wiktionary` | `en.wiktionary.org` | |
| `yp` | `yelp` | `www.yelp.com` | |
| `yt` | `youtube` | `www.youtube.com` | [:framed_picture:](#youtube) |
diff --git a/actions.js b/actions.js
index d0979fa..7b2e6e1 100644
--- a/actions.js
+++ b/actions.js
@@ -26,70 +26,71 @@ actions.getURLPath = ({ count = 0, domain = false } = {}) => {
return path
}
-actions.copyURLPath = ({ count, domain } = {}) =>
- () => Clipboard.write(actions.getURLPath({ count, domain }))
+actions.copyURLPath = ({ count, domain } = {}) => () => Clipboard
+ .write(actions.getURLPath({ count, domain }))
-// Whois/DNS lookup
-// ----------------
+// Site/Page Information
+// ---------------------
const domainDossierUrl = "http://centralops.net/co/DomainDossier.aspx"
-actions.showWhois = ({ hostname = util.getCurrentLocation("hostname") } = {}) =>
- () => actions.openLink(`${domainDossierUrl}?dom_whois=true&addr=${hostname}`, { newTab: true })()
+actions.showWhois = ({ hostname = util.getCurrentLocation("hostname") } = {}) => () => actions.openLink(`${domainDossierUrl}?dom_whois=true&addr=${hostname}`, { newTab: true })()
-actions.showDns = ({ hostname = util.getCurrentLocation("hostname"), verbose = false } = {}) =>
- () => {
- let u = ""
- if (verbose) {
- u = `${domainDossierUrl}?dom_whois=true&dom_dns=true&traceroute=true&net_whois=true&svc_scan=true&addr=${hostname}`
- } else {
- u = `${domainDossierUrl}?dom_dns=true&addr=${hostname}`
- }
- actions.openLink(u, { newTab: true })()
+actions.showDns = ({ hostname = util.getCurrentLocation("hostname"), verbose = false } = {}) => () => {
+ let u = ""
+ if (verbose) {
+ u = `${domainDossierUrl}?dom_whois=true&dom_dns=true&traceroute=true&net_whois=true&svc_scan=true&addr=${hostname}`
+ } else {
+ u = `${domainDossierUrl}?dom_dns=true&addr=${hostname}`
}
+ actions.openLink(u, { newTab: true })()
+}
+
+const googleCacheUrl = "https://webcache.googleusercontent.com/search?q=cache:"
+
+actions.showGoogleCache = ({ href = util.getCurrentLocation("href") } = {}) => () => actions.openLink(`${googleCacheUrl}${href}`, { newTab: true })()
+
+const waybackUrl = "https://web.archive.org/web/*/"
+
+actions.showWayback = ({ href = util.getCurrentLocation("href") } = {}) => () => actions.openLink(`${waybackUrl}${href}`, { newTab: true })()
// Surfingkeys-specific actions
// ----------------------------
-actions.createHint = (selector, action = Hints.dispatchMouseClick) =>
- () => Hints.create(selector, action)
+actions.createHint = (selector, action = Hints.dispatchMouseClick) => () => Hints
+ .create(selector, action)
-actions.openAnchor = ({ newTab = false, prop = "href" } = {}) =>
- a => actions.openLink(a[prop], { newTab })()
+actions.openAnchor = ({ newTab = false, prop = "href" } = {}) => a => actions.openLink(a[prop], { newTab })()
-actions.openLink = (u, { newTab = false } = {}) =>
- () => {
- if (window === undefined) {
- return
- }
- window.open(u, newTab ? "_blank" : "_self")
+actions.openLink = (u, { newTab = false } = {}) => () => {
+ if (window === undefined) {
+ return
}
+ window.open(u, newTab ? "_blank" : "_self")
+}
actions.editSettings = actions.openLink("/pages/options.html", { newTab: true })
-actions.togglePdfViewer = () =>
- chrome.storage.local.get("noPdfViewer", (resp) => {
- if (!resp.noPdfViewer) {
- chrome.storage.local.set({ noPdfViewer: 1 }, () => {
- Front.showBanner("PDF viewer disabled.")
- })
- } else {
- chrome.storage.local.remove("noPdfViewer", () => {
- Front.showBanner("PDF viewer enabled.")
- })
- }
- })
+actions.togglePdfViewer = () => chrome.storage.local.get("noPdfViewer", (resp) => {
+ if (!resp.noPdfViewer) {
+ chrome.storage.local.set({ noPdfViewer: 1 }, () => {
+ Front.showBanner("PDF viewer disabled.")
+ })
+ } else {
+ chrome.storage.local.remove("noPdfViewer", () => {
+ Front.showBanner("PDF viewer enabled.")
+ })
+ }
+})
// Site-specific actions
// =====================
// FakeSpot
// --------
-actions.fakeSpot =
- (url = util.getCurrentLocation("href")) => actions.openLink(`http://fakespot.com/analyze?url=${url}`, { newTab: true })()
+actions.fakeSpot = (url = util.getCurrentLocation("href")) => actions.openLink(`http://fakespot.com/analyze?url=${url}`, { newTab: true })()
// Godoc
// -----
-actions.viewGodoc = () =>
- actions.openLink(`https://godoc.org/${actions.getURLPath({ count: 2, domain: true })}`, { newTab: true })()
+actions.viewGodoc = () => actions.openLink(`https://godoc.org/${actions.getURLPath({ count: 2, domain: true })}`, { newTab: true })()
// GitHub
// ------
@@ -126,16 +127,14 @@ actions.gh.openRepo = () => {
const u = new URL(a.href)
const [user, repo, ...rest] = u.pathname.split("/").filter(s => s !== "")
return (
- u.origin === util.getCurrentLocation("origin") &&
- u.hash === "" &&
- u.search === "" &&
- typeof user === "string" &&
- user.length > 0 &&
- typeof repo === "string" &&
- repo.length > 0 &&
- rest.length === 0 &&
- /^([a-zA-Z0-9]+-?)+$/.test(user) &&
- !ghReservedNames.check(user)
+ u.origin === util.getCurrentLocation("origin")
+ && typeof user === "string"
+ && user.length > 0
+ && typeof repo === "string"
+ && repo.length > 0
+ && rest.length === 0
+ && /^([a-zA-Z0-9]+-?)+$/.test(user)
+ && !ghReservedNames.check(user)
)
})
Hints.create(elements, Hints.dispatchMouseClick)
@@ -147,14 +146,12 @@ actions.gh.openUser = () => {
const u = new URL(a.href)
const [user, ...rest] = u.pathname.split("/").filter(s => s !== "")
return (
- u.origin === util.getCurrentLocation("origin") &&
- u.hash === "" &&
- u.search === "" &&
- typeof user === "string" &&
- user.length > 0 &&
- rest.length === 0 &&
- /^([a-zA-Z0-9]+-?)+$/.test(user) &&
- !ghReservedNames.check(user)
+ u.origin === util.getCurrentLocation("origin")
+ && typeof user === "string"
+ && user.length > 0
+ && rest.length === 0
+ && /^([a-zA-Z0-9]+-?)+$/.test(user)
+ && !ghReservedNames.check(user)
)
})
Hints.create(elements, Hints.dispatchMouseClick)
@@ -166,18 +163,16 @@ actions.gh.openFile = () => {
const u = new URL(a.href)
const [user, repo, maybeBlob, ...rest] = u.pathname.split("/").filter(s => s !== "")
return (
- u.origin === util.getCurrentLocation("origin") &&
- u.hash === "" &&
- u.search === "" &&
- typeof user === "string" &&
- user.length > 0 &&
- typeof repo === "string" &&
- repo.length > 0 &&
- typeof maybeBlob === "string" &&
- (maybeBlob === "blob" || maybeBlob === "tree") &&
- rest.length !== 0 &&
- /^([a-zA-Z0-9]+-?)+$/.test(user) &&
- !ghReservedNames.check(user)
+ u.origin === util.getCurrentLocation("origin")
+ && typeof user === "string"
+ && user.length > 0
+ && typeof repo === "string"
+ && repo.length > 0
+ && typeof maybeBlob === "string"
+ && (maybeBlob === "blob" || maybeBlob === "tree")
+ && rest.length !== 0
+ && /^([a-zA-Z0-9]+-?)+$/.test(user)
+ && !ghReservedNames.check(user)
)
})
Hints.create(elements, Hints.dispatchMouseClick)
@@ -189,25 +184,43 @@ actions.gh.openIssue = () => {
const u = new URL(a.href)
const [user, repo, maybeIssues] = u.pathname.split("/").filter(s => s !== "")
return (
- u.origin === util.getCurrentLocation("origin") &&
- u.hash === "" &&
- u.search === "" &&
- typeof user === "string" &&
- user.length > 0 &&
- typeof repo === "string" &&
- repo.length > 0 &&
- maybeIssues === "issues" &&
- /^([a-zA-Z0-9]+-?)+$/.test(user) &&
- !ghReservedNames.check(user)
+ u.origin === util.getCurrentLocation("origin")
+ && typeof user === "string"
+ && user.length > 0
+ && typeof repo === "string"
+ && repo.length > 0
+ && maybeIssues === "issues"
+ && /^([a-zA-Z0-9]+-?)+$/.test(user)
+ && !ghReservedNames.check(user)
)
})
Hints.create(elements, Hints.dispatchMouseClick)
}
+actions.gh.openPull = () => {
+ const elements = [...document.querySelectorAll("a[href]")]
+ .filter((a) => {
+ const u = new URL(a.href)
+ const [user, repo, maybePulls] = u.pathname.split("/").filter(s => s !== "")
+ return (
+ u.origin === util.getCurrentLocation("origin")
+ && typeof user === "string"
+ && user.length > 0
+ && typeof repo === "string"
+ && repo.length > 0
+ && /^pulls?$/.test(maybePulls)
+ && /^([a-zA-Z0-9]+-?)+$/.test(user)
+ && !ghReservedNames.check(user)
+ )
+ })
+ Hints.create(elements, Hints.dispatchMouseClick)
+}
+
+actions.gh.toggleLangStats = () => document.querySelector("button.js-toggle-lang-stats").click()
+
actions.gh.goParent = () => {
const segments = util.getCurrentLocation("pathname")
.split("/").filter(s => s !== "")
- console.log(`goParent: ${segments}`)
const newPath = (() => {
const [user, repo, maybeBlob] = segments
switch (segments.length) {
@@ -220,18 +233,22 @@ actions.gh.goParent = () => {
return [user, repo]
case "pull":
return [user, repo, "pulls"]
+ default:
+ break
}
+ break
case 5:
if (maybeBlob === "blob") {
return [user, repo]
}
+ break
+ default:
+ break
}
return segments.slice(0, segments.length - 1)
})()
- console.log(`newPath: ${newPath}`)
if (newPath !== false) {
const u = `${util.getCurrentLocation("origin")}/${newPath.join("/")}`
- console.log(`newPath u: ${u}`)
actions.openLink(u)()
}
}
@@ -271,7 +288,6 @@ actions.re.toggleVisibleExpandos = (dir = 0) => () => {
} else if (dir === 1) {
sel += ".collapsed"
}
- console.log(sel)
Array.from(document.querySelectorAll(sel))
.filter(e => util.isElementInViewport(e))
.forEach(e => e.click())
@@ -323,18 +339,16 @@ actions.hn.goPage = (dist = 1) => {
// -----------
actions.ph = {}
actions.ph.openExternal = () => {
- Hints.create("ul[class^='postsList_'] > li > div[class^='item_']", p =>
- actions.openLink(
- p.querySelector("div[class^='meta_'] > div[class^='actions_'] > div[class^='minorActions_'] > a:nth-child(1)").href
- , { newTab: true }
- )())
+ Hints.create("ul[class^='postsList_'] > li > div[class^='item_']", p => actions.openLink(
+ p.querySelector("div[class^='meta_'] > div[class^='actions_'] > div[class^='minorActions_'] > a:nth-child(1)").href,
+ { newTab: true }
+ )())
}
// Dribbble
// --------
actions.dr = {}
-actions.dr.attachment = (cb = a => actions.openLink(a, { newTab: true })()) =>
- actions.createHint(".attachments .thumb", a => cb(a.src.replace("/thumbnail/", "/")))
+actions.dr.attachment = (cb = a => actions.openLink(a, { newTab: true })()) => actions.createHint(".attachments .thumb", a => cb(a.src.replace("/thumbnail/", "/")))
// Wikipedia
// ---------
@@ -348,6 +362,7 @@ actions.wp.toggleSimple = () => {
}
return s
}).filter(s => s !== "").join(".")
+ actions.openLink(u.href)()
}
module.exports = actions
diff --git a/conf.priv.example.js b/conf.priv.example.js
index a4c8ce1..103a5b9 100644
--- a/conf.priv.example.js
+++ b/conf.priv.example.js
@@ -13,11 +13,12 @@
// These are private API keys which are required for certain search completions.
// You can obtain them all for free at the supplied links.
const keys = {
- crunchbase: "", // https://about.crunchbase.com/crunchbase-basic-access/
- google_cs: "", // https://developers.google.com/custom-search/json-api/v1/overview?hl=en_US
- google_yt: "", // https://developers.google.com/youtube/v3/docs/
- wolframalpha: "", // https://products.wolframalpha.com/api/
- domainr: "", // https://market.mashape.com/domainr/domainr
+ crunchbase: "", // https://about.crunchbase.com/crunchbase-basic-access/
+ google_cs: "", // https://developers.google.com/custom-search/json-api/v1/overview?hl=en_US
+ google_yt: "", // https://developers.google.com/youtube/v3/docs/
+ wolframalpha: "", // https://products.wolframalpha.com/api/
+ domainr: "", // https://market.mashape.com/domainr/domainr
+ alternativeTo: "", // Extract the x-algolia-api-key sent with requests when typing in search box on alternativeto.net
// ****** Google Custom Search Engines ****** //
// Can be created at https://cse.google.com/cse
diff --git a/keys.js b/keys.js
index 19210c3..6e6f10a 100644
--- a/keys.js
+++ b/keys.js
@@ -12,6 +12,7 @@ const unmaps = {
"zz", "zR", "ab",
"Q", "q", "ag",
"af", ";s", "yp",
+ "", "",
],
searchAliases: {
s: ["g", "d", "b",
@@ -92,6 +93,18 @@ const maps = {
description: "Lookup all information for domain",
callback: actions.showDns({ verbose: true }),
},
+ {
+ alias: "=c",
+ category: categories.misc,
+ description: "Show Google's cached version of page",
+ callback: actions.showGoogleCache(),
+ },
+ {
+ alias: "=a",
+ category: categories.misc,
+ description: "Show Archive.org Wayback Machine for page",
+ callback: actions.showWayback(),
+ },
{
alias: ";pd",
category: categories.misc,
@@ -112,12 +125,12 @@ const maps = {
{
alias: "a",
description: "Open search result",
- callback: actions.createHint(".r>a"),
+ callback: actions.createHint("a.fl, .r>a"),
},
{
alias: "A",
description: "Open search result (new tab)",
- callback: actions.createHint(".r>a", actions.openAnchor({ newTab: true })),
+ callback: actions.createHint("a.fl, .r>a", actions.openAnchor({ newTab: true })),
},
],
@@ -192,6 +205,11 @@ const maps = {
description: "View Issue",
callback: actions.gh.openIssue,
},
+ {
+ alias: "p",
+ description: "View Pull Request",
+ callback: actions.gh.openPull,
+ },
{
leader: "",
alias: "gp",
@@ -218,6 +236,11 @@ const maps = {
description: "Copy Project Path (including domain)",
callback: actions.copyURLPath({ count: 2, domain: true }),
},
+ {
+ alias: "l",
+ description: "Toggle repo language stats",
+ callback: actions.gh.toggleLangStats,
+ },
{
alias: "D",
description: "View GoDoc for Project",
@@ -493,7 +516,15 @@ const maps = {
description: "Toggle simple version of current article",
callback: actions.wp.toggleSimple,
},
+ {
+ alias: "a",
+ description: "View page",
+ callback: actions.createHint("#bodyContent :not(sup):not(.mw-editsection) > a"),
+ },
],
}
+// Aliases
+maps["wiktionary.org"] = maps["wikipedia.org"]
+
module.exports = { unmaps, maps }