Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Bypass DNS timeouts in Safari via AppleScript Web Browsers
For some reason, Apple has given Safari very little patience in waiting for DNS queries -- it quite often gives up on a query and won't load a page, even though that page will load fine in Firefox or another browser. If you need to use Safari, though, you can use this script to look up the IP address of the site and load the page using that instead:
(*
    Bypass DNS in current tab © RickoKid 2008
    Version 0.1
  
    This script was written to get around the annoying way that Safari
    gives up very easily when waiting for a DNS lookup, but command
    line DNS lookups still work fine.
  
  
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*)

tell application "Safari"
  set webURL to ""
  set webPath to "/"
  
  set currentTab to current tab of window 1
  
  if (name of currentTab is not "Untitled") then
    set webURL to URL of currentTab
  else
    set failedWin to text of currentTab
    if failedWin contains "Safari can't open the page" then ¬
      set webURL to text ((offset of """ in failedWin) + 1) thru ((offset of """ in failedWin) - 1) of failedWin
  end if
  if webURL is equal to "" then set webURL to text returned of (display dialog "Website to visit (bypassing DNS)" default answer webURL)
  set webServer to webURL
  if webURL contains "//" then set webServer to text ((offset of "//" in webURL) + 2) thru -1 of webURL
  if webServer contains "/" then
    set webServer to text 1 thru ((offset of "/" in webServer) - 1) of webServer
    set webPath to text ((offset of webServer in webURL) + (length of webServer)) thru -1 of webURL
  end if
  set websiteIP to my nslookup(webServer)
  set newURL to ("http://" & websiteIP & webPath) as string
  log "webServer:" & webServer
  log "webPath:" & webPath
  log "websiteIP:" & websiteIP
  log "newURL:" & newURL
  
  set URL of currentTab to newURL
end tell

on nslookup(address)
  set rawResult to (do shell script "host " & address & "| head -n1")
  set AppleScript's text item delimiters to space
  set parts to text items of rawResult
  return last item of parts
end nslookup
The easiest way to use it is to add it to your Safari script menu (by putting the script file in your user's Library » Scripts » Applications » Safari folder; create the folder if necessary). You can then select it from the Scripts menu when you're trying to load a page that seems to be stuck.

Be warned, though, that sometimes the page still won't load due to virtual server redirections that happen silently when given a DNS name. (This script was originally posted in this entry on my blog.)
  Post a comment  •  Comments (4)  
  • Currently 1.60 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[8,720 views] Email Article To a Friend View Printable Version
Use Script Editor to develop bookmarklets Web Browsers
If you're developing a non-trivial bookmarklet you may be able to speed up your edit cycle by having an applescript which executes the javascript in your browser, like this:
tell application "Safari"
  activate
  do JavaScript "
    // Of course your bookmarklet code goes here, for example...
    alert('hello world');
  " in front document
end tell
I just edited the Javascript in Script Editor and hit the run button to test. Just be careful of using double quotes, and you can postpone escaping the script and adding it to your bookmarks until the very end.
  Post a comment  •  Comments (1)  
  • Currently 1.40 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[6,264 views] Email Article To a Friend View Printable Version
Access Sprint Family Locator site with Safari Web Browsers
If you are like me and love using Safari as the default browser and also subscribe to Sprint's Family Locator service, you may have to switch to Firefox in order to access their website.

Not the case anymore. You must first enable the Develop menu in Safari, which you can now do in the Advanced section of Safari's Preferences panel. (Older versions must use the solution in this hint). Then click on the Develop menu in Safari, choose User Agent, and select the latest version of Firefox for Mac from the list before you log into the Sprint Family Locator website.

You will now be able to login and browse Sprint Family Locator website with Safari. So far, I have not noticed any features that don't work when using this workaround.
  Post a comment  •  Comments (3)  
  • Currently 1.20 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[10,283 views] Email Article To a Friend View Printable Version
Use Safari to find things more easily in text files Web Browsers
You can use Safari 3.x to open Text files (they must have .rtf or .txt extensions), and then use Safari's Find feature to locate what you're looking for in the file. The advantage is that you get Safari's wonderful new 'find' UI instead of just plain old search results or filtered text.

In context, This is how I use it. There are periods of time when I do a lot of searching through log files. In doing so, I'm often looking for a particular phrase, and I also need to see the log data around that time period. Using Console just doesn't cut it for me, because when I put the search term in, Console blocks out all other data in the file. Opening the log file in TextEdit will allow me to highlight each hit individually, which is better, but still not perfect.

When I use Safari, however, it highlights all of the hits, and grays-out the other text. This allows me to quickly find associations between the search phrase and other things happening at that time. Of course, as mentioned, I do have to get the data into a .txt or .rtf file to do this, but hopefully, Safari will support other plain text extensions in the future. (Right now, if you try to drop a .log file on Safari, it will show you where it is in the Finder.)
  Post a comment  •  Comments (16)  
  • Currently 1.80 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[9,047 views] Email Article To a Friend View Printable Version
Disable the WebKit default home page Web Browsers
In my job, I jump between browsers quite regularly, usually Firefox, Camino, and Safari. As we've covered here before in various hints, you can actually run a "future" version of Safari by downloading and installing WebKit, which is a special version of Safari using newer builds of the WebKit web browser engine. WebKit builds can be faster than the currently-released version, and have bug fixes and new features that you can take advantage of. As one example, the WebKit version of Safari currently passes the Acid3 browser test with a perfect score, while the released version of Safari scores a 75 out of 100.

One minor issue with using WebKit, however, is that it sets the default 'new window' page to this page, which thanks you for helping test WebKit, and lets you know there's a new nightly build available. This constant reminder helps insure that the WebKit team doesn't get bug reports against older nightly builds, but it gets annoying relatively quickly. (As a side hint, you can use NightShift to automatically download and install new nightly builds; highly recommended.)

If you'd like your Safari home page back while using WebKit, you'll need to use a simple Terminal command, which is documented on this page on the WebKit site (quit WebKit first):
defaults write org.webkit.nightly.WebKit StartPageDisabled -bool YES
Relaunch WebKit, and it will now respect your home page setting, as set in the General tab of WebKit's Preferences panel.
  Post a comment  •  Comments (5)  
  • Currently 2.17 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (6 votes cast)
 
[10,100 views] Email Article To a Friend View Printable Version
Access all Google Docs features from Safari Web Browsers
If you are a user of Google docs (and other such Google apps) and you prefer Safari as your default browser, you will know that lots of features are lost because Safari is not a supported browser. Firefox, however, is fully supported.

If you enable the Develop menu in Safari, as covered in this hint, however, you can fix the problem. After enabling the menu, just select Develop » User Agent , and select one of the Firefox entries (2.0.x Mac, for instance), you will find that all features are enabled.

[robg adds: I'm not a huge user of Google's apps. I did, however, run a quick test with the Presentations module, and this trick certainly seemed to work. Before making the switch, I was warned that Safari wasn't fully supported, and that warning went away after changing the user agent. I also exchanged emails with the hint's author, and he states that he's not yet found an issue with a feature not working in Safari.]
  Post a comment  •  Comments (5)  
  • Currently 2.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (6 votes cast)
 
[14,929 views] Email Article To a Friend View Printable Version
Access iPhone-only web pages with Safari Web Browsers
Many web sites now have pages especially formatted for the iPhone, enabled by detecting the "user agent" for the iPhone Safari browser. You can easily visit these pages with your desktop or laptop version of Safari.

First, enable the Develop menu (as indicated in the earlier hint; it used to be called the Debug menu). Then, from the new Develop menu, select User Agent » Mobile Safari x.x.x - iPhone. Try it on Google, for example, and you'll get the right-sized iPhone Google pages. Cool.

[robg adds: Most browsers include some method of setting the user agent, so you can view iPhone-only sites in pretty much any browser you want to use.]
  Post a comment  •  Comments (7)  
  • Currently 1.80 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[11,831 views] Email Article To a Friend View Printable Version
Run Google searches by date via a bookmarklet Web Browsers
I haven't noticed it before, but you can add an as_qdr parameter to the end of a URL in Google to get a drop-down menu (next to the search box) that lets you search by date. For example:

http://www.google.com/search?&q=macosxhints&as_qdr=d

So I wrote this bookmarklet that does that automatically:
javascript:window.open(document.URL + "&as_qdr=d")
You can customize it as you please:
  • d[number]: past number of days (e.g.: d10)
  • w[number]: past number of weeks
  • y[number]: past number of years
More info on this can be found in this post on the Google Operating System site.
  Post a comment  •  Comments (4)  
  • Currently 1.40 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[7,166 views] Email Article To a Friend View Printable Version
Reorder Firefox 3 toolbar bookmarks within their menus Web Browsers
We all know that you can create folders in Firefox (I'm using Firefox 3's public beta) into which bookmarks may be placed; this aids in organization and, when these folders are placed into the bookmarks toolbar, they consume less space as the bookmarks now appear in little menus.

I discovered that you may actually drag the bookmarks that are in these Bookmarks Toolbar menus right in the menu and reorder them with having to actually open the Bookmarks dialog. Just click-and-hold, and when you drag, you'll see a small insertion line. Drag it to the desired spot, then drop.

[robg adds: This only works in Firefox 3, which is currently in developer (but public) beta -- I've actually been using Firefox 3 as my primary browser for the last month or so. While it's very stable, there are still a few bugs and things that don't quite work right, so you may not want to use it full time just quite yet. The final version should be out in the near future, though.]
  Post a comment  •  Comments (3)  
  • Currently 1.17 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (6 votes cast)
 
[7,151 views] Email Article To a Friend View Printable Version
Download any band's song off MySpace using Safari Web Browsers
So I have seen people using all types of ways to download songs off MySpace band pages, but I just found a very easy way using Safari and TextEdit or any type of text editor. First, open TextEdit (or any other program you can make a web file with) and make sure the new document setting (in Preferences) is set to plain text, then open a new file. Put in the following HTML code:
<a href="">asdad</a>
Then choose File » Save As, and change the default .txt extension in the filename to .html and hit Save. A window will appear; click Use .html to confirm the extension. Test the file by control-clicking and selecting Safari from the Open With menu. Safari should open the file and display a link. Leave the file open in TextEdit for later use.

Next, find the band page you would like to download the song from. In the menu bar in Safari, select View » View Source. In the menu bar, select Edit » Find » Find (or just press Command-F), and type embed into the find field. Near the second embed, there will be a long URL that looks something like this:
http://lads.myspace.com/music/musicplayer.swf?ABC123DEF456
(The capital letters and numbers at the end of the URL will differ each time.) Copy all of the URL, and then open it in a new tab or window. Let the song you want to download play completely. Now select Window » Activity in the menu bar. You'll see all open tabs and windows. Pick the one for the MySpace music player, and find a URL there that starts with http://cache....

Now do this next bit within 30 seconds, as MySpace refreshes the link. Double-click that cache link to open in a new window. Copy the URL and paste into the TextEdit document, placing it between the double-quotes:
 <a href="http://cache....">asdad</a>
Save the file, open it in Safari, then control-click on the link and chose Download Linked File from the contextual menu. Your song will now start to download.

[robg adds: I haven't tested this one; I imagine there may be simpler solutions, but I don't have a MySpace account.]
  Post a comment  •  Comments (8)  
  • Currently 1.77 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (13 votes cast)
 
[91,300 views] Email Article To a Friend View Printable Version