[source:style] clean up

This commit is contained in:
Maddison Hellstrom 2019-09-10 16:54:32 -07:00
parent 3ece5e1366
commit 2ad6e979b6
2 changed files with 59 additions and 44 deletions

View File

@ -9,8 +9,8 @@ const actions = {}
// URL Manipulation/querying // URL Manipulation/querying
// ------------------------- // -------------------------
actions.vimEditURL = () => Front actions.vimEditURL = () =>
.showEditor(util.getCurrentLocation(), (url) => { Front.showEditor(util.getCurrentLocation(), (url) => {
actions.openLink(url)() actions.openLink(url)()
}, "url") }, "url")
@ -25,39 +25,50 @@ actions.getURLPath = ({ count = 0, domain = false } = {}) => {
return path return path
} }
actions.copyURLPath = ({ count, domain } = {}) => () => Clipboard actions.copyURLPath = ({ count, domain } = {}) => () =>
.write(actions.getURLPath({ count, domain })) Clipboard.write(actions.getURLPath({ count, domain }))
actions.duplicateTab = () => actions.openLink(util.getCurrentLocation("href"), { newTab: true, active: false })() actions.duplicateTab = () =>
actions.openLink(util.getCurrentLocation("href"), { newTab: true, active: false })()
// Site/Page Information // Site/Page Information
// --------------------- // ---------------------
const domainDossierUrl = "http://centralops.net/co/DomainDossier.aspx" const ddossierUrl = "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(`${ddossierUrl}?dom_whois=true&addr=${hostname}`, { newTab: true })()
actions.showDns = ({ hostname = util.getCurrentLocation("hostname"), verbose = false } = {}) => () => { actions.showDns = ({ hostname = util.getCurrentLocation("hostname"), verbose = false } = {}) => () => {
let u = "" let u = ""
if (verbose) { if (verbose) {
u = `${domainDossierUrl}?dom_whois=true&dom_dns=true&traceroute=true&net_whois=true&svc_scan=true&addr=${hostname}` u = `${ddossierUrl}?dom_whois=true&dom_dns=true&traceroute=true&net_whois=true&svc_scan=true&addr=${hostname}`
} else { } else {
u = `${domainDossierUrl}?dom_dns=true&addr=${hostname}` u = `${ddossierUrl}?dom_dns=true&addr=${hostname}`
} }
actions.openLink(u, { newTab: true })() actions.openLink(u, { newTab: true })()
} }
const googleCacheUrl = "https://webcache.googleusercontent.com/search?q=cache:" const googleCacheUrl = "https://webcache.googleusercontent.com/search?q=cache:"
actions.showGoogleCache = ({ href = util.getCurrentLocation("href") } = {}) => () => actions.openLink(`${googleCacheUrl}${href}`, { newTab: true })() actions.showGoogleCache = ({ href = util.getCurrentLocation("href") } = {}) =>
() => actions.openLink(`${googleCacheUrl}${href}`, { newTab: true })()
const waybackUrl = "https://web.archive.org/web/*/" const waybackUrl = "https://web.archive.org/web/*/"
actions.showWayback = ({ href = util.getCurrentLocation("href") } = {}) => () => actions.openLink(`${waybackUrl}${href}`, { newTab: true })() actions.showWayback = ({ href = util.getCurrentLocation("href") } = {}) =>
() => actions.openLink(`${waybackUrl}${href}`, { newTab: true })()
const outlineUrl = "https://outline.com/"
actions.showOutline = ({ href = util.getCurrentLocation("href") } = {}) =>
() => actions.openLink(`${outlineUrl}${href}`, { newTab: true })()
// Surfingkeys-specific actions // Surfingkeys-specific actions
// ---------------------------- // ----------------------------
actions.createHint = (selector, action) => () => { actions.createHint = (selector, action) => () => {
if (typeof action === "undefined") { if (typeof action === "undefined") {
// Use manual reassignment rather than default arg so that we can pre-compile without access
// to the Hints object
action = Hints.dispatchMouseClick // eslint-disable-line no-param-reassign action = Hints.dispatchMouseClick // eslint-disable-line no-param-reassign
} }
Hints.create(selector, action) Hints.create(selector, action)
@ -87,10 +98,13 @@ actions.togglePdfViewer = () => chrome.storage.local.get("noPdfViewer", (resp) =
} }
}) })
actions.previewLink = actions.createHint("a[href]", a =>
Front.showEditor(a.href, url => actions.openLink(url)(), "url"))
// FakeSpot // FakeSpot
// -------- // --------
actions.fakeSpot = (url = util.getCurrentLocation("href")) => actions.fakeSpot = (url = util.getCurrentLocation("href")) =>
actions.openLink(`http://fakespot.com/analyze?ra=true&url=${url}`, { newTab: true, active: false })() actions.openLink(`https://fakespot.com/analyze?ra=true&url=${url}`, { newTab: true, active: false })()
// Site-specific actions // Site-specific actions
// ===================== // =====================
@ -255,7 +269,8 @@ actions.gh.openPull = () => {
Hints.create(elements, Hints.dispatchMouseClick) Hints.create(elements, Hints.dispatchMouseClick)
} }
actions.gh.toggleLangStats = () => document.querySelector("button.js-toggle-lang-stats").click() actions.gh.toggleLangStats = () =>
document.querySelector("summary[title='Click for language details']").click()
actions.gh.goParent = () => { actions.gh.goParent = () => {
const segments = util.getCurrentLocation("pathname") const segments = util.getCurrentLocation("pathname")

View File

@ -172,7 +172,7 @@ completions.fa = {
name: "firefox-addons", name: "firefox-addons",
search: "https://addons.mozilla.org/en-US/firefox/search/?q=", search: "https://addons.mozilla.org/en-US/firefox/search/?q=",
compl: "https://addons.mozilla.org/api/v4/addons/autocomplete/?q=", compl: "https://addons.mozilla.org/api/v4/addons/autocomplete/?q=",
callback: parseFirefoxAddonsRes callback: parseFirefoxAddonsRes,
} }
// Firefox Themes // Firefox Themes
@ -181,7 +181,7 @@ completions.ft = {
name: "firefox-themes", name: "firefox-themes",
search: "https://addons.mozilla.org/en-US/firefox/search/?type=statictheme&q=", search: "https://addons.mozilla.org/en-US/firefox/search/?type=statictheme&q=",
compl: "https://addons.mozilla.org/api/v4/addons/autocomplete/?type=statictheme&q=", compl: "https://addons.mozilla.org/api/v4/addons/autocomplete/?type=statictheme&q=",
callback: parseFirefoxAddonsRes callback: parseFirefoxAddonsRes,
} }
// Firefox Extensions // Firefox Extensions
@ -190,7 +190,7 @@ completions.fe = {
name: "firefox-extensions", name: "firefox-extensions",
search: "https://addons.mozilla.org/en-US/firefox/search/?type=extension&q=", search: "https://addons.mozilla.org/en-US/firefox/search/?type=extension&q=",
compl: "https://addons.mozilla.org/api/v4/addons/autocomplete/?type=extension&q=", compl: "https://addons.mozilla.org/api/v4/addons/autocomplete/?type=extension&q=",
callback: parseFirefoxAddonsRes callback: parseFirefoxAddonsRes,
} }
// OWASP Wiki // OWASP Wiki
@ -650,47 +650,47 @@ completions.dd.callback = response => JSON.parse(response.text).map(r => r.phras
// DuckDuckGo - I'm Feeling Lucky // DuckDuckGo - I'm Feeling Lucky
completions.D = { completions.D = {
alias: "D", alias: "D",
name: "duckduckgo-lucky", name: "duckduckgo-lucky",
search: "https://duckduckgo.com/?q=\\", search: "https://duckduckgo.com/?q=\\",
compl: "https://duckduckgo.com/ac/?q=\\", compl: "https://duckduckgo.com/ac/?q=\\",
callback: completions.dd.callback, callback: completions.dd.callback,
} }
// DuckDuckGo Images // DuckDuckGo Images
completions.di = { completions.di = {
alias: "di", alias: "di",
name: "duckduckgo-images", name: "duckduckgo-images",
search: "https://duckduckgo.com/?ia=images&iax=images&q=", search: "https://duckduckgo.com/?ia=images&iax=images&q=",
compl: "https://duckduckgo.com/ac/?ia=images&iax=images&q=", compl: "https://duckduckgo.com/ac/?ia=images&iax=images&q=",
callback: completions.dd.callback, callback: completions.dd.callback,
} }
// DuckDuckGo Videos // DuckDuckGo Videos
completions.dv = { completions.dv = {
alias: "dv", alias: "dv",
name: "duckduckgo-videos", name: "duckduckgo-videos",
search: "https://duckduckgo.com/?ia=videos&iax=videos&q=", search: "https://duckduckgo.com/?ia=videos&iax=videos&q=",
compl: "https://duckduckgo.com/ac/?ia=videos&iax=videos&q=", compl: "https://duckduckgo.com/ac/?ia=videos&iax=videos&q=",
callback: completions.dd.callback, callback: completions.dd.callback,
} }
// DuckDuckGo News // DuckDuckGo News
completions.dn = { completions.dn = {
alias: "dn", alias: "dn",
name: "duckduckgo-news", name: "duckduckgo-news",
search: "https://duckduckgo.com/?iar=news&ia=news&q=", search: "https://duckduckgo.com/?iar=news&ia=news&q=",
compl: "https://duckduckgo.com/ac/?iar=news&ia=news&q=", compl: "https://duckduckgo.com/ac/?iar=news&ia=news&q=",
callback: completions.dd.callback, callback: completions.dd.callback,
} }
// DuckDuckGo Maps // DuckDuckGo Maps
completions.dm = { completions.dm = {
alias: "dm", alias: "dm",
name: "duckduckgo-maps", name: "duckduckgo-maps",
search: "https://duckduckgo.com/?ia=maps&iax=maps&iaxm=places&q=", search: "https://duckduckgo.com/?ia=maps&iax=maps&iaxm=places&q=",
compl: "https://duckduckgo.com/ac/?ia=maps&iax=maps&iaxm=places&q=", compl: "https://duckduckgo.com/ac/?ia=maps&iax=maps&iaxm=places&q=",
callback: completions.dd.callback, callback: completions.dd.callback,
} }
@ -706,19 +706,19 @@ completions.go.callback = response => JSON.parse(response.text)[1]
// Google Images // Google Images
completions.gi = { completions.gi = {
alias: "gi", alias: "gi",
name: "google-images", name: "google-images",
search: "https://www.google.com/search?tbm=isch&q=", search: "https://www.google.com/search?tbm=isch&q=",
compl: "https://www.google.com/complete/search?client=chrome-omni&gs_ri=chrome-ext&oit=1&cp=1&pgcl=7&ds=i&q=", compl: "https://www.google.com/complete/search?client=chrome-omni&gs_ri=chrome-ext&oit=1&cp=1&pgcl=7&ds=i&q=",
callback: completions.go.callback, callback: completions.go.callback,
} }
// Google - I'm Feeling Lucky // Google - I'm Feeling Lucky
completions.G = { completions.G = {
alias: "G", alias: "G",
name: "google-lucky", name: "google-lucky",
search: "https://www.google.com/search?btnI=1&q=", search: "https://www.google.com/search?btnI=1&q=",
compl: "https://www.google.com/complete/search?client=chrome-omni&gs_ri=chrome-ext&oit=1&cp=1&pgcl=7&q=", compl: "https://www.google.com/complete/search?client=chrome-omni&gs_ri=chrome-ext&oit=1&cp=1&pgcl=7&q=",
callback: completions.go.callback, callback: completions.go.callback,
} }