Last active
March 3, 2026 03:34
-
-
Save travis-wellthy/b12beea532259ccc3b40221dd1fc70c7 to your computer and use it in GitHub Desktop.
Apple Script for Velja - Google Chrome Incognito.app Browser
This file contains hidden or 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
| (* | |
| Velja → “Google Chrome Incognito” browser option (macOS) | |
| Goal: | |
| - Create a small macOS .app that Velja can treat as a “browser” | |
| - When Velja sends a URL to this app, the app launches Google Chrome in Incognito mode | |
| and opens the URL in a new Incognito window. | |
| ------------------------------------------------------------ | |
| STEP-BY-STEP SETUP | |
| ------------------------------------------------------------ | |
| 1) Open Script Editor | |
| - Finder → Applications → Utilities → Script Editor | |
| - Create a new script (File → New) | |
| 2) Paste this entire script into Script Editor | |
| 3) Export as an Application (.app) | |
| - File → Export… | |
| - File Format: “Application” | |
| - Name: “Google Chrome Incognito.app” | |
| - Save it somewhere stable (recommended): /Applications | |
| Notes: | |
| - Exporting (not saving) is important. You want an actual .app bundle. | |
| - Putting it in /Applications makes it easy to select later and avoids moved-path issues. | |
| 4) Test it from Terminal (optional but recommended) | |
| - This confirms macOS is passing the URL into your app correctly. | |
| Run: | |
| open -a "/Applications/Google Chrome Incognito.app" "https://example.com" | |
| Expected result: | |
| - Chrome opens an Incognito window and loads https://example.com | |
| 5) Add it to Velja as a “browser” | |
| - Open Velja → Settings | |
| - Go to Browsers | |
| - Add as Browser / Alternative Browser / Click "Choose..." to add to the list of Shown Browsers | |
| - Select “Google Chrome Incognito.app” (the app you exported) | |
| 6) Use it | |
| - Trigger Velja’s picker and choose “Google Chrome Incognito” | |
| - Or create Velja rules to automatically route certain domains to it | |
| ------------------------------------------------------------ | |
| SCRIPT | |
| ------------------------------------------------------------ | |
| *) | |
| -- When the app is used like a browser, macOS commonly delivers URLs via “open location”. | |
| -- Velja typically sends the URL to the chosen browser target this way. | |
| on open location theURL | |
| -- Launch Chrome in a NEW instance (-n) and pass command-line args (--args) | |
| -- Use Incognito and force a new window, then open the URL. | |
| do shell script "open -na 'Google Chrome' --args --incognito --new-window " & quoted form of theURL | |
| end open location | |
| -- Sometimes macOS (or certain apps) send inputs via “open” with a list of items | |
| -- (URLs and/or files). This keeps the wrapper robust. | |
| on open theItems | |
| repeat with anItem in theItems | |
| set asText to anItem as text | |
| -- If we got an http/https URL, treat it as a normal web link. | |
| if asText starts with "http://" or asText starts with "https://" then | |
| do shell script "open -na 'Google Chrome' --args --incognito --new-window " & quoted form of asText | |
| else | |
| -- Otherwise, treat it as a file and open it as a file:// URL. | |
| -- (Handy if you ever use the wrapper for local files.) | |
| set p to POSIX path of anItem | |
| do shell script "open -na 'Google Chrome' --args --incognito --new-window " & quoted form of ("file://" & p) | |
| end if | |
| end repeat | |
| end open | |
| -- If the app is launched directly (double-click) with no URL provided, | |
| -- just open a fresh Incognito window. | |
| on run | |
| do shell script "open -na 'Google Chrome' --args --incognito --new-window" | |
| end run | |
| (* | |
| ------------------------------------------------------------ | |
| TROUBLESHOOTING NOTES | |
| ------------------------------------------------------------ | |
| - If Chrome is already running: | |
| Using “open -na” forces a new Chrome instance, which helps ensure your flags | |
| (like --incognito) take effect reliably. | |
| - If you prefer not to spawn a new Chrome instance every time: | |
| Change: | |
| open -na 'Google Chrome' | |
| to: | |
| open -a 'Google Chrome' | |
| (But note: flags can be less reliable when reusing an existing running instance.) | |
| *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment