Does that really matter in the end? If you're against writing code for ads/optimizing for quick dopamine hits, is it really so different to be writing the code that shows the ads vs the code that sets up the infrastructure to serve the ads? Or even infrastructure to support the developers who write the code for the ads?
If you don't want to support the ad-driven internet, don't work for companies who's entire business model is extracting as much data from users as possible in order to show the "right" ads.
Or you know, just don't work for companies who tend to collect as much user data as they can?