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

Revised script to toggle Safari cookies Web Browsers
I modified a script from this hint of phow4rd to toggle Safari's Accept Cookies setting from 'Never' to 'Only from sites I visit.'

Here is the modified script. You can save it to ~/Library/Scripts/Applications/Safari to make it available from the AppleScript menu. You may need to create the Safari folder.
tell application "Safari" to activate
tell application "System Events"
 tell application process "Safari"
  click menu item "Preferences…" of menu "Safari" of ¬
   menu bar item "Safari" of menu bar 1
 end tell
 tell application "System Events"
  click button "Security" of tool bar 1 of window 1 of ¬
   application process "Safari"
  delay 1
  if the value of radio button "Never" of radio group 1 of group 1 of group 1 of window "Security" of application process "Safari" is 0 then
   click radio button "Never" of ¬
    radio group 1 of group 1 of group 1 of window "Security" of application process "Safari"
  else
   click radio button "Only from sites I visit" of ¬
    radio group 1 of group 1 of group 1 of window "Security" of application process "Safari"
  end if
  get value of radio button "Never" of ¬
   radio group 1 of group 1 of group 1 of window "Security" of application process "Safari"
  copy the result as number to varResult
  if varResult = 1 then
   set varResult to "'Never'"
  else
   set varResult to "'Only from sites I visit'"
  end if
  click button 1 of window "Security" of application process "Safari"
  display dialog ("\"Toggle Cookies On/Off \" script Confirmation:" & ¬
   return & return & "'Accept Cookies' is set now to " & varResult & ".") ¬
   buttons {"OK"} default button "OK" giving up after 3 with icon 1
 end tell
end tell


[crarko adds: I tested this, and it works as described. The AppleScript source is mirrored here.]
    •    
  • Currently 1.57 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (14 votes cast)
 
[4,136 views]  

Revised script to toggle Safari cookies | 1 comments | Create New Account
Click here to return to the 'Revised script to toggle Safari cookies' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Revised script to toggle Safari cookies
Authored by: SwissMac on Aug 21, '10 10:09:48AM

What I would find really useful would be a script that enabled me to select "Accept cookies for current session only". This is possible in Firefox, but not in Safari, and it's a great frustration.



[ Reply to This | # ]