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

Automatically zoom new pages in Safari Web Browsers
Safari has a nice feature to zoom in (or out) on a webpage, which is great for large monitors. Unfortunately, you're not able to set a default zoom level for new pages. CSS hacks exist, but zooming via CSS doesn't seem to work as well as the native zoom function in Safari. The AppleScript in this hint zooms in on any new web page using Safari's own zoom function.

The script is quite a hack -- it checks every tenth of a second to see if the currently active tab isn't zoomed in. If it's not zoomed in, the script activates the corresponding keyboard shortcuts to zoom the page. You can edit the script to change how often the zoom-check should be made, and what level of zoom should be made.
repeat
  try -- we have to try, since safari might not be running, and theUrl might not be defined
    if frontmost of application "Safari" then
      tell application "Safari"
        set theUrl to URL of current tab of window 1 -- window 1 is apparently always the active window in Safari
      end tell
      if theUrl is not "" then -- this will ignore new tabs where a page is not yet loaded
        tell application "System Events"
          tell process "Safari"
            -- these may differ according to the OS X language
            set activeMenuItem to enabled of menu item "Actual Size" of menu "View" of menu bar item "View" of menu bar 1
          end tell
          if not activeMenuItem then
            -- here we fire off the key shortcuts 
            -- these may differ according to the OS X language
            keystroke "+" using command down
            keystroke "+" using command down
          end if
        end tell
      end if
    end if
  end try
  delay 0.1 -- how many seconds to wait until next check
end repeat
With a delay of 100ms, the scripts gobbles 1% of the CPU time on my system. One idea is to make an application from the script, and launch that instead of launching the script directly from the AppleScript Editor. Any suggestions for improvement are welcome!

[robg adds: I tested this in 10.6.2 on a MacBook Pro, and the script used about 5% of the CPU. It did, however, work as described.]
  Post a comment  •  Comments (7)  
  • Currently 2.42 / 5
  You rated: 2 / 5 (24 votes cast)
 
[12,596 views] Email Article To a Friend View Printable Version
Programmatically change URLs for Opera Speed Dial links Web Browsers
I like to keep a weather page from Wunderground on my Opera speed dial. The monthly summary page contains the information I'm seeking (moon phase and sunrise/sunset). However, the URL contains a date, and the page displays information for that date. I was changing the date manually once a month, but this method doesn't show accurate daily information. So, I wrote a perl script that changes the date every day. I use cron to run the script at midnight every day (I hate launchd; it's overly complicated).

Opera stores information about Speed Dial links in a text file located at ~/Library » Preferences » Opera Preferences » speeddial.ini. This script closes Opera and changes the date in the URL in the speeddial.ini file.
read more (110 words)   Post a comment  •  Comments (7)  
  • Currently 1.93 / 5
  You rated: 4 / 5 (15 votes cast)
 
[8,003 views] Email Article To a Friend View Printable Version
Re-enable text-only zoom in Safari Web Browsers
While reading a recent hint submission by cooter, I realized that Safari on my Mac Pro wasn't capable of zooming just the text on a web page -- regardless of the setting of the View -> Zoom Text Only menu item, Safari would always zoom both the text and the graphics. This didn't happen on my MacBook Pro, so I suspected some previously-tested hint was interfering with Safari on the Mac Pro.

After a bit of searching, I found the culprit: Implement full page zoom in the WebKit browser. A quick check in Terminal...

defaults read com.apple.Safari | grep WebKitDebugFullPageZoomPreferenceKey

...confirmed that this value was set for Safari on the Mac Pro, and not on my MacBook pro. The solution was simple -- quit Safari and delete the troublesome key in Terminal:

defaults delete com.apple.Safari WebKitDebugFullPageZoomPreferenceKey

On relaunch, Safari once again respected the setting of the Zoom Text Only menu item. (This key causes the same problem in Safari in both 10.5 and 10.6, though I'm not sure if the key survives an upgrade from 10.5 to 10.6 -- my Mac Pro is still running 10.5.8.)
  Post a comment  •  Comments (5)  
  • Currently 2.19 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (16 votes cast)
 
[9,012 views] Email Article To a Friend View Printable Version
Convert non-clickable links to clickable links Web Browsers
This bookmarklet will convert "cold-links" (i.e. URLs which do not link) into clickable hotlinks. This is from the krapplack.de collection of bookmarklets, where you can find a number of other potentially useful bookmarklets.

Create a new bookmark with a name like Linkify, and use the following text as the address (or whatever your browser labels the URL field):
javascript:(function(){var%20D=document;%20D.body.normalize();%20F(D.body);%20function%20F(n){var%20u,A,M,R,c,x;%20if(n.nodeType==3){%20u=n.data.search(/https?\:\/\/[^\s]*[^.,;'%22>\s\)\]]/);%20if(u>=0)%20{%20M=n.splitText(u);%20R=M.splitText(RegExp.lastMatch.length);%20A=document.createElement(%22A%22);%20A.href=M.data;%20A.appendChild(M);%20R.parentNode.insertBefore(A,R);%20}%20}else%20if(n.tagName!=%22STYLE%22%20&&%20n.tagName!=%22SCRIPT%22%20&&%20n.tagName!=%22A%22)for(c=0;x=n.childNodes[c];++c)F(x);%20}%20})();
I added this to my Safari bookmarks bar at the far left, so I can invoke it just by hitting Command-1.

[robg adds: I haven't tested this one.]
  Post a comment  •  Comments (7)  
  • Currently 2.88 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (16 votes cast)
 
[10,610 views] Email Article To a Friend View Printable Version
Enable extensions in Chromium (or Chrome) Web Browsers
Chromium (and Chrome) has lots of useful features that can only be enabled via command line switches when launching, such as extensions, user script support, and bookmark sync.

Rather than launch via the command line every time, I use the following script to patch the --enable-extensions command line arguments into the application bundle itself:
#!/bin/sh
# Patches the Chromium application installation with command line arguments to enable extensions.
set -o errexit
app=${1:-/Applications/Chromium.app}
cat >$app/Contents/MacOS/Chromium.wrapper <<EOF
#!/bin/sh
exec $app/Contents/MacOS/Chromium --enable-extensions "\$@"
EOF
chmod 755 $app/Contents/MacOS/Chromium.wrapper
defaults write $app/Contents/Info CFBundleExecutable Chromium.wrapper
Additional arguments that can be useful are --enable-sync and --enable-user-scripts.

[robg adds: To use the above, save it in Terminal text editor, make it executable (chmod a+x scriptname), and then run the script. You can find Chromium Mac builds here, and this hint explains how to automatically update to the latest build. I tested this script, and it seemed to work with the latest build of Chromium. Note that the script assumes Chromium is in /Applications; if you have it elsewhere, you'll need to modify the app=... line.]
  Post a comment  •  Comments (11)  
  • Currently 2.74 / 5
  You rated: 5 / 5 (23 votes cast)
 
[50,966 views] Email Article To a Friend View Printable Version
How to remove locally-stored Flash 'cookies' Web Browsers
This may be old news, but I just found out about Flash Cookies (otherwise known as Local Shared Objects), and a way to delete them, and to prevent more from being created.

You can control Flash cookies via Macromedia's Flash Player Settings Manager, which is an actual Flash application you load in your browser (that is, the picture you'll see on that page is not an image; it is the actual Settings Manager).

Set Global Storage Settings to 0, and then select the Website Privacy Settings tab (the fourth tab from the left), and select Delete All Sites to remove prior-stored history.

Note that the 'cookies' are (or were) stored in ~/Library » Preferences » Macromedia » Flash Player » #SharedObjects, and the settings are stored in ~/Library » Preferences » Macromedia » Flash Player » macromedia.com » support » flashplayer » sys.
  Post a comment  •  Comments (7)  
  • Currently 3.20 / 5
  You rated: 5 / 5 (35 votes cast)
 
[48,662 views] Email Article To a Friend View Printable Version
A possible solution for system hang on Safari launch Web Browsers
Recently, any time I tried to run Safari on 10.6 caused all apps and the Finder to hang with the spinning beach ball. Force-quitting Safari stopped the problem, but it would occur again on the next launch. Googling around, I saw many folks reporting similar problems, but no solutions.

The /var/log/system.log file shows something like this when this hang occurs:

Nov 13 09:51:16 bvmbook Safari[394]: INSERT-HANG-DETECTED: Tx time:46.498542, # of Inserts: 0, # of bytes written: 0, Did shrink: YES

Sounds like a database problem. So I looked at which database-type files were opened by Safari, with this in Terminal:
sh-3.2# lsof / | grep Safari |grep db
Safari    544       vanetten  txt    REG   14,2     32768 3762252 /private/var/db/mds/messages/se_SecurityMessages
Safari    544       vanetten  txt    REG   14,2     51288 3764181 /private/var/folders/L2/L2wz7UsyFWOAKlDB6i6RqE+++TM/-Caches-/mds/mdsDirectory.db
Safari    544       vanetten  txt    REG   14,2 197840896 3762198 /private/var/db/dyld/dyld_shared_cache_x86_64
Safari    544       vanetten    5u   REG   14,2     36864 3764157 /Users/vanetten/Library/Safari/WebpageIcons.db
Safari    544       vanetten    6u   REG   14,2  39143424 2858942 /private/var/folders/L2/L2wz7UsyFWOAKlDB6i6RqE+++TM/-Caches-/com.apple.Safari/SafeBrowsing.db
Safari    544       vanetten    7u   REG   14,2    724992 3764162 /Users/vanetten/Library/Caches/com.apple.Safari/Cache.db
I found that if I quit Safari and deleted the *.db files in my home directory, the problem goes away:
sh-3.2# rm /Users/vanetten/Library/Safari/WebpageIcons.db /Users/vanetten/Library/Caches/com.apple.Safari/Cache.db /Users/vanetten/Library/Caches/com.apple.Safari/Cache.db-journal
I'm not sure which of these files were corrupt, but launching Safari seems to re-create them.
  Post a comment  •  Comments (4)  
  • Currently 2.43 / 5
  You rated: 3 / 5 (28 votes cast)
 
[14,520 views] Email Article To a Friend View Printable Version
Set Firefox profile directly within the application bundle Web Browsers
I share a computer with my wife (using one account), and we both use Firefox and many of the same services (Gmail, Facebook, etc.). As such, it can be quite a hassle to keep track of who logged in last and who added what bookmarks.

Fortunately, Firefox provides the capability to have separate profiles for just such a situation. Unfortunately, it is not very simple to set up an easy and consistent way to launch those profiles. So, here are some of the options I tried before arriving at what I think is a pretty good solution.
read more (738 words)   Post a comment  •  Comments (17)  
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (15 votes cast)
 
[7,659 views] Email Article To a Friend View Printable Version
Zoom Firefox windows via scroll wheel Web Browsers
Firefox (versions 3.5 and up, at least) has the ability to zoom in and out of a web page, adjusting both text and graphics, without affecting the rest of the screen. You can access this feature via the menus (View » Zoom In or Zoom Out), and via the noted keyboard shortcuts (Command-equals to zoom in; Command-minus to zoom out; Command-0 to reset).

What you may not know is that you can also zoom via your mouse's scroll wheel. Press Control-Command (Control-Option also works) and move the scroll wheel up or down. The browser window will zoom in or out while maintaining, for the most part, the clarity of the text and images. The rest of the screen does not change.
  Post a comment  •  Comments (1)  
  • Currently 3.04 / 5
  You rated: 3 / 5 (24 votes cast)
 
[8,377 views] Email Article To a Friend View Printable Version
10.6: An AppleScript to check complete page loading in Safari Web Browsers
Snow Leopard only hintThis code will basically run until the currently-loading page is done loading in Safari. This code is working in Safari 4.0.3 running on OS X 10.6; I haven't tested in other versions of Safari or the OS. [robg adds: To use this script, save it to your user's Library » Scripts » Applications » Safari folder (create any of those folders if they don't exist). I'm not positive, but I think the idea here is that you can use this script if you're on a very slow connection and/or trying to load a very slow-loading page. Just put the URL into Safari, press Return, then run the above script via the Script menu item. You can then just wait for your Mac to say loaded when the page is done loading.

I had trouble finding a site that would load slowly enough to let me invoke the script, but I eventually found one; the script works as described in 10.6 (it won't compile in 10.5).]
  Post a comment  •  Comments (4)  
  • Currently 1.82 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (17 votes cast)
 
[9,711 views] Email Article To a Friend View Printable Version