Open the current Safari tab in Firefox Developer Edition
Some month ago I decided to split the browser I’m using for development from that one which I use for my everyday tasks. From that day on I used Safari for that everyday tasks. It is a very nice and fast browser. Since Apple introduced that extensions and one had not to go the SIMBL way anymore that browser made an enormous progress in the discipline of speed and energy efficiency. However, there is a feature that is (for me) horrible to use: The developer tools. As Google Chrome had a much better approach, I sticked to Chrome for development.
Roughly a month ago Mozilla released Firefox Developer Edition. A browser adjusted to fulfill all the stuff that developers need for their everyday work. Seriously, it is a really nice alternative to the developer tools shipped with Google Chrome.
Nevertheless, there is one thing that is a really big pain in the neck if you use two different browsers. There are many(!) situations were you want to open the current web page in a different browser. One thing that you can do is copy & paste that URL. This is very time consuming and not really “2014”. As there are tools available like Alfred you no longer need to do things like this manually. For Chrome I always used the Alfred2URLInChrome workflow. You just open the Alfred window type in “Firefox” and there you are. Guess what! A similar Alfred workflow for Firefox is not available.
On Mac OS X there is Apple Script which is a nice and easy programming language that is perfect for those tasks. There is only one requirement: The Application must provide a directory (you can check for this if you open the “Script Editor” and click on File › Open Directory
and select the application). Guess what! Firefox does not provide such a directory.
At least Firefox does support shortcuts (the life-saver for my wish). The idea now was to simply open Firefox and then simulate the shortcuts that open a new tab, paste the URL and open it. In Apple Script you can realize this as follows:
tell application "Safari"
set vURL to URL of current tab of window 1
set the clipboard to vURL
end tell
tell application "FirefoxDeveloperEdition"
activate
delay 1.2 #You have to change this depending on how fast your application launches
tell application "System Events"
tell process "FirefoxDeveloperEdition"
keystroke "t" using {command down} # open new tab
keystroke "l" using {command down} # select url bar
keystroke "v" using {command down} # paste the url
key code 36 # return key
end tell
end tell
end tell
Then I only had to include that script in an Alfred workflow (which is really easy…). Finally, I was able to use my missed workflow again: Open Alfred, type in “firefox” and open that URL in Firefox (developer edition). If you have a similar problem is a had feel free to grab the Apple Script above and create a workflow from that. To do so you can use the “Keyword to script template” which you will find under + > Templates > Essentials > Keyword to script
and set the panel properties as follows:
Update (22/12/14):
@maclemon reminded me that there is an alternative (and less complex) method to achieve the desired behavior. Mac OS X allows the user to add custom shortcuts for every application. The only thing the user has to provide is the exact name of the menu item. Safari has a menu item that allows the user to open the current website in an alternative Browser (Develop › Open Page With
). If you create a shortcut that searches for a menu item with the name of the Browser (The Version must also be included – e.g. “Firefox (34.0.5)”), you can simply open the current webpage by pressing a shortcut. This is much easier than the Alfred method.
However, there is also a disadvantage. Every time the browser gets an version bump you need to adjust that shortcut, because of the version number in the menu item – if you do not want to do that, use the Alfred method instead.