-- Включает в Сафари галочки разработчика: «Разрешить событиям Apple Events выполнять JavaScript» -- и «Разрешить удаленную автоматизацию». Запуск: osascript enable-safari-dev.applescript -- Требует разрешения «Системные события» для терминала (macOS спросит сам, один раз). on setCheckbox(el, wantTitle, depth) tell application "System Events" set kids to {} try set kids to UI elements of el end try repeat with k in kids set r to "" set t to "" try set r to (role of k) as text end try try set t to (title of k) as text end try if r is "AXCheckBox" and t is wantTitle then set v to "0" try set v to (value of k) as text end try if v is "1" then return true click k delay 0.5 try if (value of k) as text is "1" then return true end try return false end if if depth < 9 then if my setCheckbox(k, wantTitle, depth + 1) then return true end if end repeat return false end tell end setCheckbox tell application "System Events" tell process "Safari" -- окно настроек: открыть (⌘,) если не открыто set cfgWin to missing value repeat with w in (every window) if (name of w) as text does not contain "Авито" then set cfgWin to w exit repeat end if end repeat if cfgWin is missing value then keystroke "," using command down delay 1.5 repeat with w in (every window) if (name of w) as text does not contain "Авито" then set cfgWin to w exit repeat end if end repeat end if if cfgWin is missing value then return "окно настроек не найдено" repeat with i from 1 to 3 set ok1 to my setCheckbox(cfgWin, "Разрешить событиям Apple Events выполнять JavaScript", 0) set ok2 to my setCheckbox(cfgWin, "Разрешить удаленную автоматизацию", 0) if ok1 and ok2 then exit repeat delay 0.5 end repeat return "JavaScript: " & ok1 & "; автоматизация: " & ok2 end tell end tell