Apple Script not working on m2 Mac mini with lates osx

Hello,

I have two macs that are set up almost the same way. One is a mac mini m2. The other is an intel-based MacBook air. The script works great on the intel computer. However, on the m2 it doesn't work. They are running the same osx and the latest safari.

Did you set up Safari to execute "do javascript" AppleScript command?

tell application "Safari"
	make new document with properties {URL:"http://piyocast.com/as"}
end tell

If this script works, AppleScript itself works with Safari.

tell application "Safari"
	set aRes to do JavaScript "var selObj = window.getSelection();
	var selStr = (selObj).getRangeAt(0);
	unescape(selStr);" in front document
end tell

display dialog aRes

If this script does not work, you have to allow Safari to execute "do JavaScript" command.

Safari v10 or later exhibit to execute "do JavaScript" command by default. You have to enable "Develop" menu from Safari's preferences setting. And....execute "Allow JavaScript from Apple Events" command from Safari'sDevelop menu (this operation require admin password).

I wrote an ebook about 7 AppleScript-able web browser scripting (PDF 330pages). Scripting about Safari, Google Chrome, Chromium, Microsoft Edge, Vivaldi, Brave Browser and Opera.

https://piyomarusoft.booth.pm/items/3664077

I wrote about this issue in my ebook.

Apple Script not working on m2 Mac mini with lates osx
 
 
Q