Repository navigation
Spotify Web 1.66 - Ad blocking now uses a daily-updated hosts list and catches ad audio by its ID
Reworks ad blocking. The app now downloads a fresh list of ad hosts every time it starts, blocks more of Spotify's own ad and tracking addresses, and recognises ad audio even when it comes from the same kind of address as music.
The list is built every day from the Brave, uBlock Origin and AdGuard filters plus a hand-kept list of extra ad hosts, and published on the app's GitHub page. If a download fails, the last downloaded copy stays in use. Until the first download succeeds, the app uses the copy built into it.
The app also watches what Spotify's player reports about the current track. When a track is marked as an ad, the app notes its audio file and silences requests for it. Blocked audio is replaced with silence, and other blocked requests get an empty reply.
When Spotify queues an ad right after the song that is playing, the app now points that song's end at the next song, so the ad usually never starts: no ad bar, no break screen, no pause. If Spotify's next try for the same ad leaves no other song to point to, the app now plays the next song itself, a moment (about 1.5 seconds) before the playing song ends, so that try is usually left out too. It does this through the web page's own player when it can reach it (skipping inside the page's queue, and putting the song back if the page lands past it), and with a plain play command when it cannot. Pressing next while such an ad is due now goes to the next song too, and nothing is skipped from the app when another device is the one playing. If an ad still gets through it plays as silence and Spotify skips it, as before.
With Debug Logging on, the Logger now shows ad blocking under the tag adblock (search tag:adblock): each blocked host, list downloads and reloads, ad IDs received, ads found in Spotify's player state, ads that reached the screen and ads left out.
The Adblocking mode switch (Instant and Dynamic) is gone from Settings, because ad blocking now works one way. A value saved by an older version is ignored.
Adds Block podcast ad hosts to Settings, off by default. When it is on, omny.fm, tritondigital.com and adswizz.com are blocked too. They are off by default because blocking them may break playback of some podcasts (needs further testing).
Some of Spotify's own ad and tracking addresses (audio-ads, ads-fa, pixel and a few more) are now blocked for everyone. A few Spotify-internal addresses that the old list blocked, such as analytics and log hosts, are no longer blocked.
The ad audio detection, the silent audio file and parts of the blocking are adapted from SpotiDuck by 23fpsz. The ad markers, the idea of leaving an ad out of the playback state and the idea of playing the next song shortly before a song ends, and the way the page's own player is reached for that, follow what Myspoti by kota-zo documents. Thanks to both authors.
Limits: Until the first download, the built-in list is only as new as the app version. An ad can still show for about a second when Spotify puts it first after the early play, or when Spotify's page does not accept the redirect; it then plays as silence and is skipped. If Spotify's page ever goes blank, blocking Spotify's own ad addresses is one possible cause.