Allow JavaScript from Apple Events in Safari through Terminal Mac

只愿长相守 提交于 2019-12-04 02:33:57

It's in Safari's preferences plist at ~/Library/Preferences/com.apple.Safari.plist. The key you want is AllowJavaScriptFromAppleEvents. You can set it using defaults:

#to turn it on
defaults write -app Safari AllowJavaScriptFromAppleEvents 1
#to turn it off
defaults write -app Safari AllowJavaScriptFromAppleEvents 0
user11682464

The virtual keyboard thing did not work for me. As StarPlayr at apple's develepoer forum has found out the problem is in something else. For me problem occurred when i tried to do that on remote mac. For some people plugging in a keyboard and mouse to the Server allowed to turn on JavaScript Apple Events in Safari and set the password.

However, for me that wasn't an option, so the next best thing is use an accessbility scripting feature and have the machine think a user is doing the clicks, allowing you to set the password:

-- The delays can be shorter, coordinates may vary

-- Best way to get the coordinates is with Apple screen capture (command-shift-3) from upper right to lower left (the coordinates will be shown)

-- if one spends the time, the click events can be converted to Accessibility AppleScript objects by capturing them as variables, or checking the events and using the events instead of the click coordinates

tell application "System Events"


  tell application "Safari"

       activate

  end tell


  delay 1

-- click develop menu (make sure its on first)

  click at {430, 12}


  delay 1


-- click Allow Javascript menu from Apple Events

  click at {615, 615}


  delay 1


-- Click the Allow Button

  click at {1010, 386}

end tell
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!