here is a more recent versions, replaced query argument
on alfred_script(q)
set userQuery to text ((offset of "?" in q)+1) thru -1 of q
tell application "Safari" to activate
delay 1
tell application "System Events" to tell process "Safari"
keystroke "," using command down
delay 1
tell window 1
click button "Privacy" of tool bar 1
delay 1
click button "Manage Website Data…" of group 1 of group 1
delay 1
keystroke (userQuery)
delay 5
keystroke tab
delay 1
keystroke "a" using command down
click button "Remove" of sheet 1
click button "Done" of sheet 1
end tell
keystroke "w" using command down
end tell
end alfred_script