As a prerequisite, you'll need to install the RCDefaultApp preference pane https://github.com/Lord-Kamina/SwiftDefaultApps
Open AppleScript Editor and paste in content of _Script.scpt
Save the document using file format Application, and select the Stay Open checkbox. Name it SafariURLHelper. I have an Applications folder in my home directory in which I saved it. Using the Finder, navigate to where you saved SafariURLHelper, then Control-click its icon and select Show Package Contents from the contextual menu. Inside the Contents folder, find Info.plist, and open it in a text editor.
Add content of Info.plist to the bottom of the file, just before the closing and tags
If you had already run the script without this improvement, quit it using "Activity Monitor.app". You can also update the saved Helper app in Script Editor without the need to edit the Info.plist again - our changes are preserved.