Skip navigation

To add the AppleScript Script Menu to your Mac’s Menu Bar navigate into /System/Library/CoreServices/Menu Extras and double-click on the Script file. Then use this menu to locate and run application specific scripts.

For AppleScripts that act on the Mac’s GUI (such as the example which follows) you’ll need to Enable access for assistive devices in System Preferences>Universal Access.

Here’s my version of a cookieMonster AppleScript to use while Safari is running, to kill a specific website’s cookies — useful when they start bugging you to register or egregiously cross linking with other sites.

Run the script, refresh the website’s page and if they were tracking you in cookies they’ll now probably think that you’re a new visitor to their site.

Copy Paste the script into your AppleScript Editor and then edit in the domain of the offending website only after you have manually checked that searching for this domain in the Safari>Preferences>Security>Show Cookies targets only the cookies you intend to delete.

-- slappHappe's Safari cookieMonster
-- AppleScript to snipe at a specific website's cookies
-- Use when Safari is running in the foreground
-- Works through the Apple/Safari GUI
-- Does NOT directly parse your ~/Library/Cookies/Cookies.plist
-- Tested against Safari v5.0.4 in Mac OS 10.6.6

set targetWebsite to "" -- Whose cookies do you want to target?

tell application "Safari" to activate
tell application "System Events" to tell process "Safari"
click menu item 6 of menu 1 of menu bar item 2 of menu bar 1 -- Safari Preferences
tell window 1
click button -3 of tool bar 1 -- Security tab
click button 1 of group 1 of group 1 -- Show Cookies
keystroke targetWebsite -- Website to search for
keystroke tab
keystroke "a" using command down -- Select All
click button 1 of sheet 1 -- Remove All
end tell
keystroke return -- Done
keystroke "w" using command down -- Close window
end tell

This AppleScript will delete a specific website’s cookies while Safari is running. Works in Mac OS X 10.6 with Safari 5.

When run, tested and ready to install, use the Script Menu (installed above) to Open Scripts Folder>Open Safari Scripts Folder and then drag your Safari cookieSniper.scpt AppleScript into it. The actual location of the folder is ~/Library/Scripts/Applications/Safari. Close the window and now look for your Safari cookieSniper script at the bottom of the Script Menu when Safari is active and running in the foreground.

One Comment

  1. Thanks for the trick 😉

    AppleScript Menu can also be added in the Mac’s Menu in Script Editor Preferences/General

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s