diff --git a/actions.js b/actions.js index 6b758a6..e4ad8d8 100644 --- a/actions.js +++ b/actions.js @@ -9,8 +9,8 @@ const actions = {} // URL Manipulation/querying // ------------------------- -actions.vimEditURL = () => Front - .showEditor(util.getCurrentLocation(), (url) => { +actions.vimEditURL = () => + Front.showEditor(util.getCurrentLocation(), (url) => { actions.openLink(url)() }, "url") @@ -25,39 +25,50 @@ 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 })) -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 // --------------------- -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 } = {}) => () => { let u = "" 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 { - u = `${domainDossierUrl}?dom_dns=true&addr=${hostname}` + u = `${ddossierUrl}?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 })() +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 })() +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 // ---------------------------- actions.createHint = (selector, action) => () => { 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 } 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 // -------- 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 // ===================== @@ -255,7 +269,8 @@ actions.gh.openPull = () => { 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 = () => { const segments = util.getCurrentLocation("pathname") diff --git a/completions.js b/completions.js index bae9661..837bc68 100644 --- a/completions.js +++ b/completions.js @@ -172,7 +172,7 @@ completions.fa = { name: "firefox-addons", search: "https://addons.mozilla.org/en-US/firefox/search/?q=", compl: "https://addons.mozilla.org/api/v4/addons/autocomplete/?q=", - callback: parseFirefoxAddonsRes + callback: parseFirefoxAddonsRes, } // Firefox Themes @@ -181,7 +181,7 @@ completions.ft = { name: "firefox-themes", search: "https://addons.mozilla.org/en-US/firefox/search/?type=statictheme&q=", compl: "https://addons.mozilla.org/api/v4/addons/autocomplete/?type=statictheme&q=", - callback: parseFirefoxAddonsRes + callback: parseFirefoxAddonsRes, } // Firefox Extensions @@ -190,7 +190,7 @@ completions.fe = { name: "firefox-extensions", search: "https://addons.mozilla.org/en-US/firefox/search/?type=extension&q=", compl: "https://addons.mozilla.org/api/v4/addons/autocomplete/?type=extension&q=", - callback: parseFirefoxAddonsRes + callback: parseFirefoxAddonsRes, } // OWASP Wiki @@ -650,47 +650,47 @@ completions.dd.callback = response => JSON.parse(response.text).map(r => r.phras // DuckDuckGo - I'm Feeling Lucky completions.D = { - alias: "D", - name: "duckduckgo-lucky", - search: "https://duckduckgo.com/?q=\\", - compl: "https://duckduckgo.com/ac/?q=\\", + alias: "D", + name: "duckduckgo-lucky", + search: "https://duckduckgo.com/?q=\\", + compl: "https://duckduckgo.com/ac/?q=\\", callback: completions.dd.callback, } // DuckDuckGo Images completions.di = { - alias: "di", - name: "duckduckgo-images", - search: "https://duckduckgo.com/?ia=images&iax=images&q=", - compl: "https://duckduckgo.com/ac/?ia=images&iax=images&q=", + alias: "di", + name: "duckduckgo-images", + search: "https://duckduckgo.com/?ia=images&iax=images&q=", + compl: "https://duckduckgo.com/ac/?ia=images&iax=images&q=", callback: completions.dd.callback, } // DuckDuckGo Videos completions.dv = { - alias: "dv", - name: "duckduckgo-videos", - search: "https://duckduckgo.com/?ia=videos&iax=videos&q=", - compl: "https://duckduckgo.com/ac/?ia=videos&iax=videos&q=", + alias: "dv", + name: "duckduckgo-videos", + search: "https://duckduckgo.com/?ia=videos&iax=videos&q=", + compl: "https://duckduckgo.com/ac/?ia=videos&iax=videos&q=", callback: completions.dd.callback, } // DuckDuckGo News completions.dn = { - alias: "dn", - name: "duckduckgo-news", - search: "https://duckduckgo.com/?iar=news&ia=news&q=", - compl: "https://duckduckgo.com/ac/?iar=news&ia=news&q=", + alias: "dn", + name: "duckduckgo-news", + search: "https://duckduckgo.com/?iar=news&ia=news&q=", + compl: "https://duckduckgo.com/ac/?iar=news&ia=news&q=", callback: completions.dd.callback, } // DuckDuckGo Maps completions.dm = { - alias: "dm", - name: "duckduckgo-maps", - search: "https://duckduckgo.com/?ia=maps&iax=maps&iaxm=places&q=", - compl: "https://duckduckgo.com/ac/?ia=maps&iax=maps&iaxm=places&q=", + alias: "dm", + name: "duckduckgo-maps", + search: "https://duckduckgo.com/?ia=maps&iax=maps&iaxm=places&q=", + compl: "https://duckduckgo.com/ac/?ia=maps&iax=maps&iaxm=places&q=", callback: completions.dd.callback, } @@ -706,19 +706,19 @@ completions.go.callback = response => JSON.parse(response.text)[1] // Google Images completions.gi = { - alias: "gi", - name: "google-images", - 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=", + alias: "gi", + name: "google-images", + 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=", callback: completions.go.callback, } // Google - I'm Feeling Lucky completions.G = { - alias: "G", - name: "google-lucky", - 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=", + alias: "G", + name: "google-lucky", + 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=", callback: completions.go.callback, }