This userscript redirects open.spotify.com links to the desktop app
< Spotify open in appについてのフィードバック
Here's a script that does what you want https://greasyfork.org/en/scripts/445028-spotify-don-t-open-in-app, the "Opening Spotify" screen is still there, but the userscript runs before it has time to do anything so it does not matter. Method I'm using is not hacky and should not break unless there are drastic changes in the redirect flow, but if you have any issues please make sure to report them so I can fix them.
Is there a way to do the opposite with a script? When I open a spotify track or album from discord for example, it first opens the web player, but simultaneously wants to open the app (eg. https://open.spotify.com/track/7mJoAyRnCYVLGRvLhTnGuU?si=a7bd42afc8f940b5). I would like to not receive the "Open Spotify app?" confirmation window, and would like to use the web player only.