3 ms·
When the link is in a different app (e.g email client), the click event is handled by the OS and the URI is sent to the “default app” for that URI schema (for h
by xk_id 3y ago
When the link is in a different app (e.g email client), the click event is handled by the OS and the URI is sent to the “default app” for that URI schema (for http/https, that would be your default browser). You can therefore reconfigure your OS to use a different app for that schema.
On Mac, you can for example create a simple App in AppleScript with the following code:
on open location the_url
do shell script "/path/script.sh" & quoted form of the_url
end open location
Then, using a tool like “SwiftDefaultApps”, you can configure this new AppleScript app to be the default app for the http/https schema.
In script.sh, which receives the clicked url as the its first positional argument, you can then run any arbitrary logic that you require.
So this idea would work if the links you wanted to open were coming from another app. If they come from inside the browser, I would suggest writing an additional browser extension that replaces all http/https links in a page with an invented URI schema, like newschema://. Then the browser would pass those links to the OS for handling and then you would have full control over how to handle this new schema.
Hope this makes sense.
- Aachen 3y agoThat makes sense and I knew this, but browsers are the main use case for me, not external programs
- xk_id 3y agoYeah, so your script.sh could send the URI received in its positional argument to a browser with the configuration you need (and substitute newscheme:// to https:// https://). I think it’s 100% doable