Skip to content

Instantly share code, notes, and snippets.

@slmingol
Created April 20, 2019 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slmingol/781e5eaeb87c24e50a55ad5064cd528f to your computer and use it in GitHub Desktop.
Save slmingol/781e5eaeb87c24e50a55ad5064cd528f to your computer and use it in GitHub Desktop.
Example AppleScript to Reset Advertising Identifier on macOS under System Preferences -> Security & Privacy
#!/bin/bash
### REF: https://apple.stackexchange.com/questions/357209/automating-reset-advertising-identifier-is-it-possible/357211?noredirect=1#comment471757_357211
osascript << END
if running of application "System Preferences" then
try
tell application "System Preferences" to quit
on error
do shell script "killall 'System Preferences'"
end try
end if
repeat while running of application "System Preferences" is true
delay 0.01
end repeat
tell application "System Preferences"
activate
reveal anchor "Privacy" of pane "com.apple.preference.security"
end tell
tell application "System Events" to tell application process "System Preferences"
repeat while not (exists (window "Security & Privacy"))
delay 0.1
end repeat
select row 12 of table 1 of scroll area 1 of tab group 1 of window "Security & Privacy"
repeat while not (exists (button "Reset Advertising Identifier" of group 1 of tab group 1 of window "Security & Privacy"))
delay 0.1
end repeat
click button "Reset Advertising Identifier" of group 1 of tab group 1 of window "Security & Privacy"
repeat while not (exists (button "Reset identifier" of sheet 1 of window "Security & Privacy"))
delay 0.1
end repeat
click button "Reset identifier" of sheet 1 of window "Security & Privacy"
repeat until not (exists (sheet 1 of window "Security & Privacy"))
delay 0.1
end repeat
end tell
quit application "System Preferences"
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment