-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update shortcuts-search extension (#14516)
* Update shortcuts-search extension - Update changelog - Minor refactoring - Extract exitWithMessage to separate file - Remove hostname hook - Ignore www subdomain - Improve error handling for web shortcuts - Move keymap operations to ShortcutsList - Extract ShortcutsList to separate file - Extract KeymapDropdown to separate file - Extract shortcut formatter to separate file - Extract baseKeySymbolOverride to separate file - Add basic support for web app shortcuts - Bump next from 14.1.1 to 14.2.12 in /shortcuts-disco-site - Add web app hostname for Fastmail - Use chokidar for shortcut file watching during development. Rewrite combine-apps in Node.js. - Add a watcher that can prettify and combine JSON files on each source file edit. Make this run in combination with \`next dev\`, which already has its own file watcher. - Lock down the node version 20, remove unused ts-node - Bump micromatch from 4.0.5 to 4.0.8 in /shortcuts-disco-site - Add shortcuts for SQLPro Studio (through SetApp) - Add shortcuts for Figma - Add shortcuts for Postman - Remove newlines in some .json files to align with prettify.ts output - Fix FreshRSS favorite toggle shortcut - Extend Firefox shortcuts - Extend Notion shortcuts - Add shortcuts for Signal - Add shortcuts for Spotify - Update root readme - Add shortcuts for Discord - Add shortcuts for FreshRSS - Remove duplicated shortcut - Add shortcuts for Numbers - Add shortcuts for OmniFocus 4 - Add shortcuts for OmniFocus3 - Bump braces from 3.0.2 to 3.0.3 in /shortcuts-raycast-extension - Bump ws from 8.16.0 to 8.17.1 in /shortcuts-disco-site - Fix Pixelmator Pro bundle id - Update README with new prettify script - Prettify shortcut files - Add shortcuts prettier script - Reformat 1Password shortcuts - Initial Pixelmator Pro shortcuts - Bump next from 14.1.0 to 14.1.1 in /shortcuts-disco-site - Update single app title and description metadata - Add header - Fix case #60 - Spline - Update links to GitHub repo - Add VCS shortcuts section for IntelliJ IDEA - Update manifest and metadata description - Add Toggle Full Screen from MacOS - Fix sitemap for about page - Add opengraph and twitter images - Rebrand for Hotkys * Fix lint * Add description for each command
- Loading branch information
1 parent
53b58e2
commit ced6239
Showing
19 changed files
with
334 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
extensions/shortcuts-search/src/engine/frontmost-hostname-fetcher.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { runAppleScript } from "@raycast/utils"; | ||
|
||
//language=JavaScript | ||
const appleScript = ` | ||
const chromium = new Set([ | ||
"com.google.Chrome", | ||
"com.google.Chrome.beta", | ||
"com.google.Chrome.canary", | ||
"com.vivaldi.Vivaldi", | ||
"com.brave.Browser", | ||
"com.microsoft.edgemac", | ||
"com.operasoftware.Opera", | ||
"org.chromium.Chromium", | ||
]); | ||
const safari = new Set(["com.apple.Safari", "com.apple.SafariTechPreview"]); | ||
const arc = new Set(["company.thebrowser.Browser"]); | ||
function getFrontmostChromiumLink(bundleId) { | ||
const tab = Application(bundleId).windows[0].activeTab(); | ||
return tab.url(); | ||
} | ||
function getFrontmostSafariLink(bundleId) { | ||
const tab = Application(bundleId).documents[0]; | ||
return tab.url(); | ||
} | ||
function getFrontmostArcLink(bundleId) { | ||
const tab = Application(bundleId).windows[0].activeTab; | ||
return tab.url(); | ||
} | ||
function getFrontmostApp() { | ||
const apps = Application("System Events") | ||
.applicationProcesses | ||
.where({ frontmost: true }); | ||
return apps[0].bundleIdentifier(); | ||
} | ||
function getFrontmostLink() { | ||
const app = getFrontmostApp(); | ||
if (chromium.has(app)) { | ||
return getFrontmostChromiumLink(app); | ||
} else if (safari.has(app)) { | ||
return getFrontmostSafariLink(app); | ||
} else if (arc.has(app)) { | ||
return getFrontmostArcLink(app); | ||
} else { | ||
return null; | ||
} | ||
} | ||
function run(argv) { | ||
return getFrontmostLink(); | ||
} | ||
`; | ||
|
||
function extractHostname(url: string): string { | ||
const match = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:/\n?]+)/im); | ||
return match ? match[1] : url; | ||
} | ||
|
||
export async function getFrontmostHostname(): Promise<string | null> { | ||
const url = await runAppleScript(appleScript, { language: "JavaScript" }); | ||
return url && url !== "null" ? extractHostname(url) : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.