Allow Javascript in second user account

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)

The plot thickens… I just discovered that this problem is specific to my Mac Pro. I ran a test on my MacBook Pro and there was no problem. Clearly there is something wrong with my Mac Pro. Booting in Safe mode does not eliminate the problem. I’ve solved my immediate problem my eliminating all the “do JavaScript” commands in the script I was trying to run. Perhaps this issue will be resolved when I upgrade to High Sierra in a few more months.