I have some AppleScripts that I use to collect information from the web. Naturally they use “do JavaScript” to achieve their goals. I have “Allow Javascript from Apple Events” turned on in the Develop window. Because these scripts can take a long time to execute (8-24 hours) and they use System Events, I normally run them in a second user account. I will start a script in that account and then switch back to my main account. That way I can work on something else while the script runs on its own.
This worked fine until about 3 months ago. Now I get a message:
“Safari got an error: You must enable the ‘Allow JavaScript from Apple Events’ option in Safari’s Develop menu to use ‘do JavaScript’.” number 8
This happens as soon as my script encounters a “do JavaScript” command after I switch accounts. The script still works fine if I don’t switch accounts, but that makes my computer unusable for most of a day. I have been getting around this problem by running the scripts overnight, but sometimes 10 hours isn’t enough.
This wasn’t a problem until recently. I suspect Apple did something to cause this. Does anyone have any insight into this problem? Is there a workaround? I could modify these scripts to parse the various site’s HTML code myself and stop using JavaScript, but that would take considerable effort.
Model: Mac Pro (black can)
AppleScript: 2.9
Browser: Safari 11.0.2
Operating System: Mac OS X (10.12.6 beta 6)