How to run an AppleScript when Safari starts up?

To use uBlock Origin in Safari 12.1.1, I run it using Extension Builder 1. But I have to go by the builder tool at every Safari startup, so the blog suggested adding the script to ~/Library/Scripts/Applications/Safari. I made the necessary folders, and put the script in .scpt format there. I also locked the com.apple.Safari.Extensions.plist preferences file as said.

But restarting Safari didn't prompt me for the password which it did, when I ran the script in Script-Editor. So I think it is not running.

How can I run the script at Safari start-up? Should it be put in some different folder, or different extension?

1 https://georgegarside.com/blog/macos/install-any-safari-extension-macos-mojave/


Solution 1:

Safari won't automatically run the script on launch. The easiest way to run the script is to place the script in ~/Library/Application Scripts/com.apple.Safari, then you can run the script from the Script menu when Safari is running.

You can enable the Script menu if you haven't used it before from Script Editor, then the menu appears and shows all appropriate scripts. Enable the Application Scripts menu in Script Editor → Preferences → General under ‘Show Script menu in menu bar’.

I've updated the instructions on the linked blog post: Bypass ‘Safari no longer supports the unsafe extension’ in macOS Mojave: Next steps