How Safari Search Engine Extensions Work lapcatsoftware.com

Jeff Johnson:

To use Kagi as your default search engine in Safari, you have to install Kagi’s Safari extension.

So I installed the extension and entered a search in the Safari address bar. Note below how Safari says “Search Google” and “Google Search”, even though I’m supposed to be using Kagi.

[…]

Why does this happen? It turns out that Safari has no extension API to set a new search engine. The workaround for the lack of an API is a kind of hack: Safari extensions instead use the webNavigation onBeforeNavigate API to detect a connection to your default search engine, and then they redirect to your custom search engine using the tabs update() API. This technique is not unique to the Kagi extension. Other Safari extensions such as xSearch must do the same thing, because there’s no better way.

Michael Tsai:

Even though Chrome is made by Google, it lets you pick another search engine. Even though Edge is made by Microsoft, it doesn’t lock you into Bing, and you can add any search URL template that you want. Apple is not encumbered with its own search engine to push, yet it seems to be constrained by its desire for revenue sharing, so Safari users get stuck with fewer choices that are arguably lower quality and less private.

One other possibility is that Apple’s nominal desire for simplicity in preferences led to the company ignoring requests for an arguably niche feature like a custom search engine. Yet Safari preferences are complex and messy in other ways, and the company has — thankfully — retained legacy features like user stylesheets. Even if revenue sharing discouraged Apple from developing this feature, how many people are actually going to set a custom search engine, and would they have a meaningful impact on its beloved Google revenue stream? My guesses: very few, and I doubt it. Yet here we are, over twenty years after Safari’s launch, and we can generously choose between five search engines, of which three — Bing, DuckDuckGo, and Yahoo — are dependent on the same index.

Apple’s reluctance to add this feature to Safari is one of the main reasons I am so thankful for DuckDuckGo’s bang operations, of which there are hundreds just for other search engines. It is not identical to configuring a custom search engine — a query is still being passed through DuckDuckGo before being sent to the third-party engine — but it is frequently useful.