Jump to content

Some ideas if you use Firefox

Recommended Posts

Firefox has no AppleScript support so there are limits to what you can do. However, I have used Firefox for years and very much like it. There are some things you can do using Alfred and Firefox and I thought it might be useful to others to list them here.


If you already have Firefox running and want to browse in a private window—but not provide in Firefox settings for Firefox exclusively to use a Firefox private window—you can link a hotkey (I use ⌥⌘V) to this AppleScript:

on run
tell application "System Events"
	keystroke "w" using {shift down, command down}
	delay 1
	keystroke "p" using {shift down, command down}
end tell
end run

(I don't like GUI scripting because it's liable to break but that has worked for a number of years now).


However, I now take a slightly different approach. At the start of every day I launch Firefox in a private window with a hotkey using this AppleScript:

tell application "Firefox"
   --- Bring app to the front, starting it if necessary
end tell
-- wait a moment and then simulate Shift + Cmd + W
delay 1
tell application "System Events" to keystroke "w" using {shift down, command down}
-- Simulate Shift + Cmd + P
tell application "System Events" to keystroke "p" using {shift down, command down}


I then link that to a 2 second delay and then to a Call External Trigger action which calls a workflow that opens the websites to which I need to login. That workflow looks like this:CleanShot2024-01-24at11_16.10@2x.thumb.png.8d9f9b1b77fcea98004b7c4014e37963.png

The websites are listed in the Arg & Vars utility—each on a new line—and then split to send to the shell script, which is as follows:

for var in "$@"
/Applications/Firefox.app/Contents/MacOS/firefox --private-window "$var"

You'll see in the screen shot the point at which the external trigger, referred to above, links to this workflow.


That all sounds rather long-winded but the result is a series of websites very quickly opened in Firefox private windows as soon as Firefox is launched. (The latter workflow leaves one initial blank tab that needs to be closed but I simply do that manually.)


It is, of course, easy to create a workflow using a Universal Action limited to a single selected URL which enables you to open the selected link in a Firefox private window. Just link the Universal Action to this zsh shell script:

/Applications/Firefox.app/Contents/MacOS/firefox --private-window $1


Finally, you can alway search Google from Firefox using a DuckDuckGo bang: there is a workflow for that.


Warning: If you're using an older version of Firefox (possibly pre 121?) in the shell script code examples you'll need to change …/MacOS/firefox to …/MacOS/Firefox -bin.



Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...