top | item 30057442

Show HN: Let's Block It – Custom uBlock Origin Filters Made Easy

261 points| xvello | 4 years ago |letsblock.it | reply

uBlock Origin is more than an ad-blocker, it's a general purpose content filter that can be leveraged to hide low-quality content from pages you browse. While the main filter lists can remove mailing list popups and obvious nags, the definition of low-quality content is personal, so one size cannot fit all.

I used to have an ad-hoc script to render and publish a personal uBlock Origin filter list, added to all my browsers. The goal of this project is to enable more people to build such a list custom list to filter out low-quality content and nags. Chose from a list of community-maintained templates, set your options, add your custom rules, and get your personal filter list.

Code and content are licensed under the Apache 2.0 license and hosted on https://github.com/xvello/letsblockit. The project is still pretty young and needs more filter templates, and lots of frontend improvements (my last web project was in 2005, this is not my forte). Any feedback is welcome!

82 comments

order
[+] bambax|4 years ago|reply
Personal customized filters are a great idea! Congrats!

Here's something that might help others. On Whatsapp groups some users can become obnoxious, and one can fall into the trap of responding to their trolling. Yet AFAIK it's impossible to hide contributions from a given user in a group; one can only leave the group.

When using WhatsApp in the browser, a uBlock filter can hide contributions from a given user like this:

    web.whatsapp.com##div.message-in:has(div.copyable-text[data-pre-plain-text*="name_of_user"])
This hides text messages (even successive ones where the username isn't displayed) but doesn't hide messages with only images or other media. For those it's more difficult as the username is in a span that has no consistent characteristics; the username has to be unique and complete in order to not trigger false positives.

Or maybe there's a better way. Suggestions welcome.

[+] xvello|4 years ago|reply
That's the kind of filters I started this project for!

I would not accept this template in the project though, as I am not willing to endorse usage of Facebook/Meta's websites. This is listed in the project limitations in https://letsblock.it/help/contributing

[+] lordnacho|4 years ago|reply
Still waiting for one that blocks FB ads. I gather Meta spends a lot of effort to make it hard though, contrary to most sites I've come across. Makes sense given their business model, I don't doubt that.
[+] dsr_|4 years ago|reply
FBPurity (.com) seems to spend most of its time on that case. Works pretty well for months at a time, then FB changes something, and a new FBP update comes through a few days later.
[+] Melatonic|4 years ago|reply
I just block the entire facebook domain on NextDNS :-)
[+] aasasd|4 years ago|reply
Yandex is one company that's known to put effort into resisting ad blockers—to the point that uBlock/AdBlock filter authors had to just give up. So it's certainly possible for FB.
[+] gnud|4 years ago|reply
This filter seems to work for me, but it'll probably break soon.

    ##:xpath(//div[@role="feed"]//div[.//a[@aria-label="Sponsored"]])
[+] andrei_says_|4 years ago|reply
If you inspect the markup of Facebook ads you’ll see it’s beyond insane.
[+] jakub_g|4 years ago|reply
Side note: this remembered me back in late 2000s there was a Firefox extension called RIP (Remove It Permanently) for the same use case. And Aardvark (later: HackTheWeb) for cleaning temporarily (before printing etc). IIRC they didn't survive gradual Firefox engine changes between v20 and v57. Anyway, good old times.
[+] SquareWheel|4 years ago|reply
Just a heads up it's "reminded me", not "remembered me". When we're reminded of something, we then remember it.

I see ESL users trip on this one a lot.

[+] Melatonic|4 years ago|reply
If you want to get really fancy run uBlock in browser + NextDNS + block the IP's of all commonly known DNS on your router firewall. Then make sure everything (browsers, networking hardware, mobile devices) is doing DoH or DoT to NextDNS.

This way smart devices and apps cannot hardcode an IP for encrypted DNS to get around your DNS settings.

Works great for Roku - no more ads anywhere!

[+] greggman3|4 years ago|reply
I've wondered if twitter and similar sites (google news?) are not running afoul of any accessibility laws. I've wanted to apply ublock origin rules but twitter does not have any aria tags and all the CSS rules are auto-generated and compressed (obfuscated?) so it's hard to make any rules that don't rely on content
[+] moooo99|4 years ago|reply
I found this to be extremely annoying as well. I tried to block the trending container but it keeps being on some subpages.

It is absolutely annoying, but I think it’s a result of Twitter using react-native-web and not (primarily) an obfuscation tactic

[+] caaqil|4 years ago|reply
This is awesome. I think it'd be useful to add filters for blocking sites that just copy SO and similar websites.
[+] xvello|4 years ago|reply
Agreed! I have lots of them in my list, using https://letsblock.it/filters/search-results as a template. I'm investigating adding presets to this filter (check a box to block the SO / github clones, they'll be added to the filter input alongside your blocked sites).
[+] stevedzreams|4 years ago|reply
I didn't realise uBlock Origin was so powerful, can hide authors from websites that you don't enjoy.

theguardian.com##.fc-item__byline:has-text(Zoe Williams):upward(.fc-slice__item)

[+] jbirer|4 years ago|reply
Is this not just shoving your head in the sand though?
[+] contravariant|4 years ago|reply
If you're going to bother with accounts it's a bit annoying that you can't just contribute directly from your account. Having to create a pull request is slightly annoying.

And at this point my personal list of uBlock rules is tailored to satisfy some very specific personal needs which I'd feel a bit apprehensive about just sharing without some degree of anonymity. Heck there are rules that would allow you to identify my account on other social media.

Also if this is to get as popular as userscripts/styles are/were then some way of finding rules per webpage would be nice.

[+] xvello|4 years ago|reply
Thanks for your feedback.

As this is just a humble weekend project, I had to cut in scope in order to move forward. This is why the project has no back-office and relies on Github for content contribution. I made this choice because the uBlock, EasyPrivacy and AdGuard communities are using the same tool to maintain their lists. I am open to changing that flow later this year, but not in the immediate future.

I understand your privacy concerns, and invite you to read https://letsblock.it/help/privacy to show that I take it seriously. AFAIK, Github is pretty lenient on identity, and wouldn't blink if you opened a throwaway anonymous account to contribute. You can also keep custom rules in https://letsblock.it/filters/custom-rules without necessarily contributing them as templates.

[+] happybuy|4 years ago|reply
This is a great idea and is something similar to what I was thinking of implementing in the ad blocker that I develop.

Some suggested improvements would be to actually use domain names ('*.google.com') as the way to classify filters instead of just tags ('google'). This would make it possible to integrate with an ad blocker that automatically suggest filters to enable when you are browsing a specific website.

E.g. when you are browsing Google you could see the list of suggested filters you could enable for that site based upon the filters from letsblock.it

It would also probably be necessary to add some rating or scoring of the filters in the future to sort and flag those which are most helpful vs. those which are out of date or no longer work.

[+] danShumway|4 years ago|reply
I really like the idea, I'm less enthused about the account tie-in, even though I do get why it exists. I'm not sure off the top of my head what a better solution would even be. It is good that you can still manually maintain your own filters if you want and just copy the rules in, so there's value here even for people who don't want to make accounts.

And I do really like the effort to make this kind of stuff more accessible, I think it's understated how important it is to have a nice a site with a tutorial saying "here's how you add a filter", and that there's a ton of value in making it easier for normal people to update that. I'm happy to see people helping to meet that need.

----

I'll look into possibly making a pull request when I have more time, but for whatever it's worth, here are my HN rules that hide my own karma from me without otherwise messing with any of the site's formatting. I've found that making my own karma invisible helps me avoid some of HN's more toxic qualities:

  news.ycombinator.com##.comhead .score:style(overflow: hidden; display: inline-block; line-height: 0.1em; width: 0; margin-left: -1.9em;)
  news.ycombinator.com##.comhead:not(.sitebit):style(overflow:hidden; display: inline-block);
  news.ycombinator.com###hnmain > tbody > tr:first-of-type table td:last-of-type .pagetop:style(font-size: 0!important; color: transparent!important;)
  news.ycombinator.com###hnmain > tbody > tr:first-of-type table td:last-of-type .pagetop > *:style(font-size: 10pt; line-height: 1.45em;)
  news.ycombinator.com###logout::before:style(content: "|"; padding: 0.25em;)
  news.ycombinator.com##form.profileform tbody tr:nth-child(3)
HN is pretty annoying to customize because the generated HTML is so bad, but the site is also really static, so filters almost never need to be updated. I've got a couple more janky ones that I use for blocklisting certain users or filtering articles, but they're not really reliable or consistent enough for me to share imo.

Caveats: I haven't tested these on mobile because I tend to avoid HN on mobile anyway, but I probably should test them sometime to make sure they don't break anything there. Also, some of these rules won't completely hide the elements from screen readers. It won't break anything, it just won't get rid of every reference to your karma. Unfortunately because of how HN's HTML is set up, it's kind of tricky to do better, but maybe I can try to think of something later that works better.

[+] xvello|4 years ago|reply
Thanks for your feedback, and your filter suggestion!

The first iteration of this project was a CLI that took a yaml file (simple map of filter name -> params) and rendered the filter list to stdout. I ran that binary in a netlify pipeline to publish my list for personal use. As the filter data is hosted alongside the sources, it would be pretty simple to add back that offline rendering capability, or run a self-hosted instance.

As you said, I moved away from the CLI and towards a website to make it more accessible for everyone. The UX is still not great (especially the manual refresh via the uBlock interface), but hopefully we can improve on this front with more visibility.

[+] Daneel_|4 years ago|reply
I'd love a way to suggest ideas. For example, the 'clean up google search result' filters don't include "People also search for", which can be removed with: google.*##[id^="eob_"]
[+] xvello|4 years ago|reply
Hello! The best way for this would be to open a "Filter update" issue in the github repo: https://github.com/xvello/letsblockit/issues/new/choose. I'll make sure to add a link from the view filter page.

I was confused because the "People also ask" section is correctly hidden, and I had to google about this "People also search for" thing that pops up when you bounce back from a search result. Thanks for the pointer!

As I've seen the `eob_` id prefix on other contextual blocks, I think I'll go with a more selective filter: `google.*###rso div.g div[jscontroller]`. It hides every "smart" blocks inside organic search result entries. Deploying right now!

[+] wanderer_|4 years ago|reply
Here's the ever-present warning when employing any ad-blocking: make sure you whitelist friendly blog sites, they need your ad money to operate! (Not that there is anything wrong with this project, just keep that in mind).

I do understand that this is something completely different, and it solves a real problem. Great job! Welcome back to the game, xvello, 2005 was a long time ago...

I might pop into the repo later and see about contributing.

[+] ceejayoz|4 years ago|reply
> Here's the ever-present warning when employing any ad-blocking: make sure you whitelist friendly blog sites, they need your ad money to operate! (Not that there is anything wrong with this project, just keep that in mind).

I'd prefer blogs do what Serious Eats did for a while; if you blocked ads, they showed a message in its place saying "we get it completely, but consider donating". I'll happily donate or hop on a Patreon for a site I keep coming back to if you make it possible.

I block ads as a security measure, regardless of how much I appreciate/trust a site.

[+] keithnz|4 years ago|reply
There's no blog I know of that is worth any ads they may want to display. This broad acceptance of using ads to generate revenue has warped the internet. It encouraged tracking, and finding out as much personal details, use of AI, etc. Best thing we can do is block all ads.
[+] halpert|4 years ago|reply
That friendly blog site includes trackers. They won’t get my money until they respect my privacy.
[+] jaredlt|4 years ago|reply
It would be great to see screenshots of what each option will block. Although many are obvious, some are less clear.
[+] xvello|4 years ago|reply
Agreed! I decided to launch without it due to limited time, but will keep that in the top priorities. Contributions are welcome if some users have time to contribute screenshots!
[+] only4here|4 years ago|reply
This is a great idea, I like that you can generate lists for DuckDuckGo as well. It'd be cool to also see lists for SearX, too. I see a lot of these list websites online but this one allows for more specific use cases rather than the "block everything" ones that I usually find.
[+] xvello|4 years ago|reply
Thanks for the feedback! Adding another search engine to the search-results filter is pretty easy. For reference, the (handlebars) template for it is available at https://github.com/xvello/letsblockit/blob/main/data/filters...

The tricky part about SearX is that it runs on several domains, while uBlock Origin cosmetic filters need to be scoped to a given domain name. We'd need to add a parameter to specify the instance(s) on which you want the filter to be generated. If you want to follow up on this, would you mind opening an issue at https://github.com/xvello/letsblockit/issues/new?template=up... to help me with the testing?

[+] captn3m0|4 years ago|reply
I do some custom filters for blocking useless elements on websites (paywall popups, long-footers, useless notifications, copyright statements etc, useless images on news websites) mainly using the uBlock picker. Here's some of them: https://www.toptal.com/developers/hastebin/goconuxufi.pl, will try to suggest these to letsblockit later.
[+] darepublic|4 years ago|reply
These days what I typically want to block are the gdpr modals that pop up that demand you read and interact with a bunch of legalese or click I surrender, own me.
[+] foxfluff|4 years ago|reply
DNT was supposed to be a solution. Companies who insist on nagging you until you "voluntarily consent" are to blame. I'm not sure what killed DNT but it seems like they're trying to revive it again in Europe: https://news.ycombinator.com/item?id=30022523

No doubt companies who want to violate your privacy will lobby hard against this.

[+] irrational|4 years ago|reply
Seriously, I don’t live in Europe, so why do I have to click the cookie agreement buttons?
[+] xvello|4 years ago|reply
I agree that this is getting out of hand.

I investigated this, but as more and more websites are non-functional until you chose a consent option, just hiding the modal with a cosmetic filter won't help. There are several browser extensions to achieve this, and I feel like this is a superior solution than my project.

[+] jiriro|4 years ago|reply
Is there a way to use uBlock Origin in Safari on iPhone/Mac?
[+] dombili|4 years ago|reply
You can't¹. There is a new browser called Orion² currently in private beta that uses the same engine as Safari, which you can use Firefox and Chrome extensions on. It works both on Mac, and surprisingly on iOS. I believe it's the only browser on iOS that allows you to use -some- desktop extensions. I use uBlock Origin with it on iOS and it works good enough.

¹ https://github.com/el1t/uBlock-Safari/issues/158

² https://browser.kagi.com/

[+] cuham_1754|4 years ago|reply
Thank you so much for your work, a very easy to use interface! Hopefully you will add Facebook or Twitter post blocking in future updates!
[+] djanogo|4 years ago|reply
Why not use Firefox builtin uBlock cloud sync and just copy paste filters from this site?, instead of creating account for this website.
[+] xvello|4 years ago|reply
Very good question! You are indeed free to copy the rendered filters to your uBlock settings (there is even a button for this). I see two reasons for using the account feature:

- I would never sync the same Firefox profile on my personal and work laptops, with letsblock.it I can use the same custom list on different Firefox profiles

- Rules will eventually break when websites are updated / redesigned. When that happens, one contributor can PR the fix for everyone, and you'll get it in the next 24h (uBlock Origin's minimal filter list refresh rate)