I'm trying to implement an extension in a modern way: https://developer.apple.com/documentation/safariservices/safari_app_extensions. The idea is to improve Safari search by using keys. For instance, if you start your search with "a" it will use Amazon.com as a searching source.
Previously it was possible to use:
safari.application.addEventListener('beforeSearch', handlerFunc, false);
to react on a search try.
How to implement in a modern way?