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

A script to toggle Safari's appearance settings Web Browsers
I load a lot of pages with Safari and it can take a long time to load pages from time to time. I wrote an AppleScript that toggles appearance so that pages load faster. When I read a page that I am really interested in reading, I can then toggle appearance again and reload page.

The script is as follows:

tell application "Safari"
  activate
  tell application "System Events"
    tell application process "Safari"
      key down command
      keystroke ","
      delay 1
      key up command
    end tell (*  end application process Safari  *)
  end tell (*  end System Events   *)
  tell application "System Events"
    click button "Appearance" of tool bar 1 of window 1 of ¬
     application process "Safari"
    delay 1
    click checkbox "Display images when the page opens" of ¬
     group 1 of group of window "Appearance" of application process "Safari"
    delay 1
    click menu item "Close Window" of menu "File" of ¬
     menu bar 1 of application process "Safari"
  end tell
end tell (*  end Safari  *)
That's it. Load 'um Safari!

[robg adds: Save this script in your user's Library -> Scripts folder for easy access from the Scripts menu.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,992 views]  

A script to toggle Safari's appearance settings | 8 comments | Create New Account
Click here to return to the 'A script to toggle Safari's appearance settings' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to toggle Safari's appearance settings
Authored by: jhersco on Feb 11, '04 01:00:00PM

I copied this script into Script Editor, compiled and saved it as Run Only. When I launch the script, two things happen: First, my Safari Preferences window opened. Then, an error message appeared : "A script error occurred. System Events got an error: NSReceiverEvaluationScriptError: 4."



[ Reply to This | # ]
A script to toggle Safari's appearance settings
Authored by: robJ on Feb 11, '04 02:05:07PM

Did you go to the Universal Access pref pane and "Enable access for assistive devices"? This is required for scripts that interact via the GUI.



[ Reply to This | # ]
A script to toggle Safari's appearance settings
Authored by: roncross@cox.net on Feb 11, '04 05:07:50PM

First of all, the Safari Preference window is supposed to open. It shows that you are on the right track. The error that you are receiving is probably a result of not having the correct path to click on the appearence button - assuming that your "enable access for assitance device is enable". I wrote the scipt using Panthers operating system.

If you are using Jaquar, the path may not be correct as written in the script here. You will have to slightly modify the script to work with Jaquar. I don't have Jaquar, so I will not be able to help in this area.


---
rlc



[ Reply to This | # ]
A script to toggle Safari's appearance settings
Authored by: slartibartfast on Feb 12, '04 03:23:17AM

Are you running a localized Mac OS? In that case you have to change the script in a few places to correspond with actual names of menus, buttons, checkboxes and windows. I had to make five substitutions and now the script runs on a Swedish system.



[ Reply to This | # ]
A script to toggle Safari's appearance settings
Authored by: roncross@cox.net on Feb 12, '04 02:56:52PM

First, I want to thank you for getting this to run on your system. I hope that you will benefit from it. I guess you can say that I have a localized mac os x. This is my own Ti G4 powerbook 1GHz system with a Panther operating system that I purchased from Apple about a year ago. I am not sure how Apple develops their system with respect to different countries or differenct machines for that matter. But it would seem wise on their part to ensure that they develop systems that behave as similar as possible for compatibility reasons.

thx
RLC

---
rlc



[ Reply to This | # ]
A script to toggle Safari's appearance settings
Authored by: jhersco on Feb 13, '04 02:48:30AM

I am running a U.S. version of Panther (v10.3.2.) I am not clear on what changes, if any, I need to make in the script to avoid the error message.



[ Reply to This | # ]
A script to toggle Safari's appearance settings
Authored by: zoopiedoop on Sep 29, '07 09:50:41PM
I couldn't get this to work until I changed it from using a keystroke to using the menu.

Replace:
key down command
keystroke ","
delay 1
key up command

with:
click menu item "Preferences…" of menu 1 of menu bar item "Safari" of menu bar 1

[ Reply to This | # ]

A script to toggle Safari's appearance settings
Authored by: jhersco on Feb 13, '04 02:52:45AM

Just enabled access for assitive devices and the script works now. Sorry for the confusion.



[ Reply to This | # ]