TIL: How to declutter sites with uBlock Origin filters
Tags: todayilearned, productivity, design, browser
Published: 2024-06-12 05:00:00

_I originally posted this post on [my blog](https://canro91.github.io/2023/11/13/DeclutteringUBlockOrigin/) a long time ago in a galaxy far, far away._

I didn't know I could restyle elements on a page with uBlock Origin, a "free, open-source ad content blocker."

The other day, while reading HackerNews, I found [this submission](https://news.ycombinator.com/item?id=37584134) pointing to some uBlock Origin filters to clean up websites.

This is how to restyle a page with uBlock Origin and the filters I'm using to declutter HackerNews.

## 1. uBlock Origin filters to restyle elements

A uBlock Origin filter to restyle an element looks like this,

```
<domain>##<selector>:style(<new-css-here>)
```

For example, these are the filters I use to restyle HackerNews,

```
news.ycombinator.com###hnmain:style(background-color: #fdf6e3; width: 960px !important; margin: 0 auto !important;)
news.ycombinator.com##.rank:style(font-size: 14pt !important;)
news.ycombinator.com##.titleline:style(font-size: 16pt !important;)
news.ycombinator.com##.sitebit.comhead:style(font-size: 12pt !important;)
news.ycombinator.com##.subtext:style(font-size: 12pt !important;)
news.ycombinator.com##.spacer:style(height: 12px !important;)
news.ycombinator.com##.toptext:style(font-size: 12pt !important;)
news.ycombinator.com##.comment:style(font-size: 14pt !important;)
news.ycombinator.com##span.comhead:style(font-size: 12pt !important;)
news.ycombinator.com##.morelink:style(font-size: 14pt !important;)
```

## 2. How to install custom uBlock Origin filters in Brave

I use multiple browsers. Brave is one of them. It has good privacy defaults, like an ad blocker that uses the same filters as uBlock Origin.

To install these filters in Brave, let's navigate to `brave://settings/shields/filters`, paste the filters, and hit "Save."

If you're using uBlock Origin on another browser, click on the uBlock Origin extension icon, go to "Open the dashboard," and then to "My filters."

This is how HackerNews looked without my filters,

<figure>
<img src="https://canro91.github.io/assets/posts/2023-11-13-DeclutteringUBlockOrigin/Before.png" alt="HackerNew front page" width="800px">
<figcaption>HackerNews front page without any restyling</figcaption>
</figure>

And this is how it looks after restyling it,

<figure>
<img src="https://canro91.github.io/assets/posts/2023-11-13-DeclutteringUBlockOrigin/After.png" alt="HackerNew front page after restyling" width="800px">
<figcaption>HackerNews front page with some uBlock Origin filters</figcaption>
</figure>

I reduced the page width and the increased font size for more readability. I don't know about you, but I prefer the second one. I don't want to get eye strain getting closer to a screen to see a small font.

Voilà! That's how to use uBlock Origin filters to declutter websites. I like clean and minimalistic designs. Before learning about uBlock Origin filters, I started to dabble in browser extension development to restyle sites. With these filters, it's waaay easier.

What site would you like to declutter with this trick? What about decluttering dev.to? Share your filters in the comments.

***

_Hey, there! I'm Cesar, a software engineer and lifelong learner. Visit my [Gumroad page](https://imcsarag.gumroad.com) to download my ebooks and check my courses._

_Happy coding!_