Skip to content

Instantly share code, notes, and snippets.

@riceissa
Last active October 22, 2025 04:49
Show Gist options
  • Save riceissa/43ea884fbc13aa27b2b283a556184ff8 to your computer and use it in GitHub Desktop.
Save riceissa/43ea884fbc13aa27b2b283a556184ff8 to your computer and use it in GitHub Desktop.
uBlock Origin filters for Substack and Substack-based websites: new version at: https://github.com/riceissa/ublock-origin-substack
! New version at: https://github.com/riceissa/ublock-origin-substack
@jbm9
Copy link

jbm9 commented Jan 25, 2024

FWIW, I needed to tweak a couple of these a bit to deal with the dynamically-generated class names:

substack.com##[class*=".frontend-components-SubscribePrompt-module__subscribeDialog--"]
substack.com##[class*=".frontend-components-SubscribePrompt-module__background--"]

Thanks for posting this, it was a great starting point!

@riceissa
Copy link
Author

@jbm9 Thanks for the comment! I think when I made this Gist 10 months ago Substack was still using hard-coded class names, but I guess they got smarter about it... I've updated those two lines to use yours.

@domdomegg
Copy link

I've found targeting the .pencraft class is sufficient to work across a much wider range of substack websites, e.g.

##.pencraft [class*="_subscribeDialog_"]
##.pencraft [class*="_background_"]

@riceissa
Copy link
Author

riceissa commented Jan 3, 2025

@domdomegg If I understand your comment correctly, you're saying I can remove the list of domains and instead just add the .pencraft class. I don't want to do that because it's possible some non-Substack websites will use some of the same class names and I don't want to potentially break those sites in ways that could be hard to debug.

@domdomegg
Copy link

Yep, that is my claim. I agree there comes some risk of breaking non-substack websites, but the trade-off of having this work reliably on many different custom domains is worth it for me, and I see it as very unlikely that these specific filters match again. But fair enough not updating your overall filters, can understand this is a trade-off :)

@evfrenkel
Copy link

Seems they updated the css a bit, or maybe since I'm using adguard the filters need to be different, but this works for me now:

##.pencraft [class*="subscribeDialog"]
##.pencraft [class*="background"]

@riceissa
Copy link
Author

@evfrenkel Thank you! They do indeed seem to have updated the CSS. I've incorporated your changes.

@riceissa
Copy link
Author

For anyone who subscribed to the comments in this thread: I've moved this Gist to an actual GitHub repo now, with a generation script, and cleaned out the old rules that didn't seem to do anything anymore: https://github.com/riceissa/ublock-origin-substack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment