Allow JavaScript from Apple Events in Safari
“Allow JavaScript from Apple Events” is a Mac-only Safari setting that lets other apps on your Mac run JavaScript in your Safari tabs. You need it to script Safari with AppleScript, to run JavaScript in a tab from Shortcuts or a Keyboard Maestro macro, or to use an app like Pauseidon that controls the video in your tabs. Safari keeps it off until you turn it on, once, in Safari’s settings.
Choose Safari › Settings… from the menu bar.
Click Advanced, and turn on “Show features for web developers”. Skip this if you already see a Developer tab.
Click the Developer tab.
Turn on “Allow JavaScript from Apple Events”.
How to turn it off again
Choose Safari › Settings… again, click the Developer tab, and turn off “Allow JavaScript from Apple Events”. Apps that relied on it, like your scripts or macros, stop being able to run JavaScript in Safari.
Is it safe?
The setting doesn’t give websites anything new. It only lets apps on your Mac run JavaScript in Safari, and macOS asks you first: an app can only control Safari once you’ve approved it, and you can see or take back that approval anytime in System Settings › Privacy & Security › Automation.
An app you approve can read and change the pages you have open, so only allow apps you trust. And you can switch the setting off again whenever you like.
Using Pauseidon?
Pauseidon fixes your Mac’s play/pause key. It finds and controls the video or audio in a Safari tab by running a little JavaScript there, which is why it needs this setting on.
Once you’ve turned it on, Pauseidon notices within a few seconds: the dot on its menu bar icon goes away, and if the setup window is open, Safari gets a tick.
Pauseidon only uses this to find the video or audio in a page, show its artwork, and play or pause it.