Blocking ads on desktop Spotify, crazy code ahead
Find a file
2025-06-19 21:15:14 -05:00
src Typescript refactor and removed standard filtering 2025-06-19 21:15:14 -05:00
.editorconfig New rewrite, v2 2020-02-10 21:12:35 -06:00
.gitignore Typescript refactor and removed standard filtering 2025-06-19 21:15:14 -05:00
Dockerfile add dockerfile and updated readme 2020-03-25 16:43:28 +01:00
Dockerfile.mitm Added Dockerfile for MITM proxy 2021-04-12 16:50:48 +02:00
LICENSE Create LICENSE 2020-07-11 16:05:57 +00:00
package-lock.json Typescript refactor and removed standard filtering 2025-06-19 21:15:14 -05:00
package.json Typescript refactor and removed standard filtering 2025-06-19 21:15:14 -05:00
pnpm-lock.yaml Typescript refactor and removed standard filtering 2025-06-19 21:15:14 -05:00
README.md Typescript refactor and removed standard filtering 2025-06-19 21:15:14 -05:00
tsconfig.json Typescript refactor and removed standard filtering 2025-06-19 21:15:14 -05:00

Spotify Desktop Adblocker

This project uses a Man-In-The-Middle proxy to strip all ad-related requests from the Spotify desktop application. This should work for all major operating systems, but if you are using Linux, I would advise you to use this instead.

Installation & Usage Instructions

Click to expand for installation & usage.

Open desktop Spotify, open the dropdown from the top-right, and open settings. Scroll all the way down settings and find "Proxy" (you may need to look under Advanced Settings).

Configure it as shown:

image

Run the following commands in terminal to clone and install.

> git clone https://github.com/AnanthVivekanand/spotify-adblock.git && cd spotify-adblock
...
> npm i

Then start the proxy by running node mitm.js, which allows it to generate some certificates. Then, trust the root certificate at certs/certs/ca.crt

On MacOS, you can trust the root certficate with one command: sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain certs/certs/ca.crt

After trusting, run node mitm.js to start the proxy again. You should see something similar to the image below.

image

How it works

mitm.js uses a Man-In-The-Middle proxy to decrypt SSL connections and filter out ad-related URLs and domains. All Spotify requests are routed through a locally hosted proxy, which evaluates every request against the allow-list (src/utils/whitelist-mitm.ts) and block-list (src/utils/blacklist-mitm.ts). On first run, mitm.js generates a root Certificate Authority (CA) that must be trusted by your OS for the proxy to function.

Note: The simpler "domain-filter" flow (filter-domains.js) has been removed from the main branch. If you still need it you can check out the last commit that contains it: github.com/AnanthVivekanand/spotify-adblock@d2b6397369 .

Docker image

To build an image for the MITM proxy, simply run npm run docker-mitm, and then create a container binding the port 8082 and the folder /usr/src/app/certs to the host to get access to the certificates. The port 8082 is exposed by Docker for easier setup using a reverse-proxy.

For example:

docker run -d --name=Spotify-adblock --volume=/opt/spotify-adblock/certs:/usr/src/app/certs -p 8082:8082 --restart=always spotify-adblock:latest

,where /opt/spotify-adblock/certs is the path on the host machine where you will find the certificates you need to import.