After browsing for a few hours in Safari, it's possible to end up with a dozen windows or so because of links that open a new window (links with target="_blank"). I've always wished there was a way to have these links open in a new tab instead of a new window (sometimes referred to as single window mode).
In the latest Safari 3.1, Apple finally added a (hidden) preference to do just this! To enable single window mode, which forces all links that would normally open a new window appear in a new tab instead, we only need to enable the TargetedClicksCreateTabs preference using the following command (paste it into Terminal):
[robg adds: This worked for me, but note that it will create those new tabs in the foreground, not the background. Command-clicking the link, however, will open the page in a new tab in the background (this has always been true, as I recall). The preference setting is mostly useful for sites you haven't visited before -- with it set, you'll not have window proliferation if you just click instead of command-clicking. To undo the setting, you can just delete the preference: defaults delete com.apple.Safari TargetedClicksCreateTabs. Make sure Safari's not running before you use either command.]
I have wanted to Quick Look files directly from the browser for a while (especially .doc and .ppt files). A switch to Firefox recently exacerbated this problem, as there is no PDF plug-in. So I wrote a simple script that monitors the Downloads directory and opens any new files with qlmanage, and thought others might find it useful. Copy and paste the code below into a file (say ql_downloaded.sh) and make it executable (chmod a+x ql_downloaded.sh). Launch the script in a separate Terminal window, then start browsing.
This bit -- if [[ $i == *.(pdf|ppt|xls|doc) ]]; then -- restricts which files are Quick Looked. In Firefox, the handling option for these types of files should be set to Save to Disk. The above code should work with most any browser; it works most of the time for me, but there are still some random issues once in a while (probably due to the temporary ".part" files created during downloads). Hope you find this useful!
[robg adds: This worked for me in testing with Firefox and Safari.]
Many people are using a trick to view any YouTube video in high-quality -- simply append &fmt=18 to the end of the URL. This is a job for AppleScript! Here are two simple versions; the first, for for OmniWeb:
tell application "OmniWeb"
set current_url to the address of active tab of browser 1
set current_url to current_url & "&fmt=18"
set the address of active tab of browser 1 to current_url
...and the second, for Safari:
tell application "Safari"
set current_url to the URL of current tab of window 1
set current_url to current_url & "&fmt=18"
set URL of current tab of window 1 to current_url
These can be placed in ~/Library » Scripts » Applications » AppName for easy access via the Script menu.
The Flash plug-in stores its temporary files in /private » var » tmp » folders.501 » TemporaryItems, in files named FlashTmp0, FlashTmp1, and so on.
So if you want to do a quick save without looking at Safari's Activity window, press Command-Shift-G in the Finder (or use the Go » Go to Folder menu item), enter /tmp, and dive down the specified folder hierarchy. You can then move the FlashTmp0 file to the Desktop, add the .flv extension, and watch it with VideoLanClient, MPlayer OSX, or QuickTime with the Perian.component installed. I tested this with Safari and Firefox 3 beta.
If you migrate from a previous machine to a new machine using Apple's Migration Assistant, and in the process you create a new user -- this can happen if you create your old user account on the new machine prior to migrating -- you may have issues with Firefox and the Downloads folder. Because of a shortcoming in the migration tool, the OS X Downloads folder for the new account will have the path for the old account, and Firefox will then be unable to save because it does not have the correct permissions. I encountered this issue with 10.5 Leopard (both machines), migrating from an old Mac mini to new Mac pro.
The solution is to open ~/Library » Preferences » com.apple.internetconfig.plist with the Property List Editor (Xcode required), navigate to the Download Folder item, and delete the value (not the key; just the value under it), then save the property list file.
The next time you save a downloaded file in Firefox, OS X will ask you where you want it. Answer the question, and the problem goes away permanently.
[robg adds: A commenter on the queue review site notes: "This is a bug with Firefox that I see with our users all the time. In prefs, the download folder looks like it's set correctly, but Firefox wants to download to some read-only folder on the hard drive (it's always arbitrary). We have had to delete ~/Library » Preferences » com.apple.internetconfig.plist -- but we ALSO have had to delete ~/Library » Preferences » com.apple.LaunchServices.plist to resolve it."]
Safari 3 has resizable textareas -- multi-line text input boxes -- on its forms. This can be a big help when completing a form (for example, submitting a long hint!), but can also help with printing those forms.
By default, when Safari prints a form, it appears just as it does on screen. This means that any textareas that have more text than will fit in the visible space will show a vertical scrollbar and some of your content will be hidden -- not much help for record keeping. However, printing (including Save as PDF) honors resized textareas, so the trick is to make sure you have resized (using the handle at the bottom right corner) to show all your content before printing. You'll also get better looking output with no scrollbars!
I use this technique when submitting information to sites that don't offer a printable version after submission.
I often send a link off to one single person, many times a day. You can use the Mail Link to this Page feature in Safari, but that still means you have to compose the email with the To address, and also tell the email to send. Since I do this several times a day, I decided to AppleScript it. Drop the following script into ~/Library » Scripts » Safari; name it what you like. If that folder structure is not already made, just make new folders with the correct names.
The script will get the current URL of the frontmost document in Safari. It will not copy it to the clipboard, leaving your clipboard in the same state. The script them brings Mail.app forward, addresses an email, sets a subject, some body copy, and drops the URL into the email. Finally, a signature is added to the message, and it is sent out. After that has happened, Mail.app is set to hidden, and Safari is brought back to the foreground where you last left it.
In /Applications » AppleScript is a program called AppleScript Utility. This will enable the script menu item in the Finder. Personally, I have attached this script to a keyboard command with Keyboard Maestro. You can also use FastScripts Lite, which is free.
I occasionally find myself wanting to save some text from a browser window. Usually I want to know where the text came from as well, so just dragging out a text clipping to the desktop is not a good solution.
I wrote two AppleScripts (one for Safari and one for Firefox) to make saving a selected text, URL, and page title from browser windows easier. The scripts write the browser's selected text and other info to a text file that it creates on the user's desktop. (I don't like clutter on the desktop, so on my Mac, this file gets created in another folder. However, I wanted to provide example scripts that worked, so I chose the desktop).
Below is an example of the script's output with the date, the URL, the page title and some text from a selection:
Wednesday, February 6, 2008 8:40:11 PM
Photo of the Day
A deep-blue sky sets off a mass of yellow wildflower blooms along ... [snip] ... magazine
Further use of the script will append data to the same file, and keep the text neatly formatted and properly separated.
If you do a lot of shipping with FedEx, you know how annoying it is to cut and paste all the address information into Safari. There are expensive programs that will extract information, but most don't work with OS X or require Filemaker. Here's a quick hint I use quite often to autofill the FedEx forms.
You can easily modify this to do more programmically. For instance, I use Python and appscript to parse the emails my e-commerce solution sends, and then fill in the FedEx page with Safari. I'll leave that up to you. Even if you don't need to do that, simply autofilling most of the common fields may be a huge timesaver for you. This also demonstrates an easy way to handle forms in general.
The only bit that needs explanation is the filling in of the field shipmentDimension, which seems a tad confusing. FedEx adds a unique number for each custom box you've created. Go to Safari's View » View Source menu, search for shipmentDimension, and you'll see your custom box sizes and the numbers for each.