I need to get Safari's window title and when I enable "Allow Javascript from Apple Events" I get this warning:

So my question is: is it possible, maybe via AppleScript or Shell, to activate this momentarily (so just for this particular macro) and deactivate it when the macro ends, without showing any warning?
I found this post:
Even though it indeed created the plist file, Safari still doesn't toggle that option ON

I don't know if this will work, but it's worth a try: Add a killall cfprefsd
command after the pref setting bit. That should force the prefs system to re-read all settings from your drive. However, you probably have to relaunch Safari, too … and even then, it may not work.
-rob.
1 Like
I was able to use an AppleScript to do this and then some KM actions to do some extra steps.
Now I got this script online:
tell application "System Events"
tell application "Safari" to activate
delay 1
tell process "Safari"
-- check if developer menu is available
set menuItems to name of every menu bar item of menu bar 1
if "Develop" is not in menuItems then error "You must enable developer menu" number -1024
-- click to allow js events
click menu item "Allow JavaScript from Apple Events" of menu 1 of menu bar item "Develop" of menu bar 1
-- confirm allow
if value of static text 1 of window 1 is "Are you sure you want to allow JavaScript from Apple Events?" then click button "Allow" of window 1
end tell
end tell
I don't know if you are an AS expert or something, but I would like to use AS to add the password automatically without me relying on KM actions. Right now I have a Pause Until Found Image, followed by Insert Text by Typing, and then a Keystroke, running after the AS I shared above:

So is it possible to replace these 3 actions with something in the AS itself?
It would need something like:
1 - Pause until the next pop up is the password pop up
2 - Insert password from %Variable%Local__SafariPasswordJavascript%
3 - Press OK (or Return/Enter key)
Given this is a security feature, and Apple clearly want you to have to enter your password before enabling this feature, it's likely to be difficult and fragile to automate.
1 Like
I'm just gonna use the "manual" way then, as described above. Thanks.