Skip to content

Instantly share code, notes, and snippets.

@haapmik
Last active May 16, 2024 11:12
Show Gist options
  • Save haapmik/33741919d6b887a31ea5bb2cf63c504d to your computer and use it in GitHub Desktop.
Save haapmik/33741919d6b887a31ea5bb2cf63c504d to your computer and use it in GitHub Desktop.
uBlock origin filter list guide to hide unwanted content from various websites.

I use these uBlock filters

  • to hide zero-value content from various websites to minimize time spent on procrastination;
  • to provide better user experience.

Table of Contents

Tips

Some of these filter rules uses regular expressions, or regex for short. This is indicated by /<regex rule>/ You can find more information about it from wikipedia: https://en.wikipedia.org/wiki/Regular_expression

Visual indicator for what the rule is going to block

If you want to preview blocking rules with a visual indicator before blocking them, you can use the following rule at the end of each rule. If rule ends with :remove() option, please replace it with this one.

:style(border: 8px dotted yellow !important)

Example:

# Original rule:
www.hs.fi##article:not(:has(> article)):has(> a[href^="/urheilu"]):remove()

# Add visual indicator for the rule:
www.hs.fi##article:not(:has(> article)):has(> a[href^="/urheilu"]):style(border: 8px dotted yellow !important)

Newspapers

Helsingin Sanomat

Block articles from main feed:

# ... by link (main category):
# We need to take into account article groups which contains multiple articles.
# This is done with the `:not(:has(> article))` option that causes uBlock to
# first remove all subarticles and finally the main article in the group.
www.hs.fi##article:not(:has(> article)):has(> a[href^="/urheilu"]):remove()

# ... by title category (sub category):
# example: block all articles that uses "Kuolleet" sub category for the article
www.hs.fi##article:not(:has(> article)):has(> a > section:has(.storylogo-container:has-text(/^Kuolleet/))):remove()

# ... by title:
# example: block all articles that contains "Britney Spears" in the title
www.hs.fi##article:not(:has(> article)):has(> a > section:has(h2:has-text(/Britney Spears/i))):remove()

Block articles listed on the side panel:

# ... by link (main category):
www.hs.fi##article[class="list"] > ol > li:has(> a[href^="/urheilu"])

# ... by title category (sub category):
www.hs.fi##article[class="list"] > ol > li:has(> a:has(.storylogo-container:has-text(/^Kuolleet/)))

# ... by title:
www.hs.fi##article[class="list"] > ol > li:has(> a:has(h3:has-text(/^Taylor Swift/)))

Iltasanomat

These rules should work for both mobile and desktop browsers.

Block articles from main feed:

# ... by link
# We need to take into account article groups which contains multiple articles.
# This is done with the `:not(:has(> article))` option that causes uBlock to
# first remove all subarticles and finally the main article in the group.
www.is.fi##article:not(:has(> article)):has(> a[href^="/urheilu"]):remove()

# ... by title with regex,
# example: titles like "yllättävään tilanteeseen" or "yllättävän kauhea tilanne" are blocked with this:
www.is.fi##article:not(:has(> article)):has(> a:has(span:has-text(/yllättävä.+ tilan/i))):remove()
# example: titles which include an exclamation mark, e.g. "Jättipotti meni jakoon!"
www.is.fi##article:not(:has(> article)):has(> a:has(span:has-text(/!/))):remove()

# ... by whitelisting only allowed title categories,
# example: use non-casesensitive filter for "Politiikka", "Kotimaa", and "Taloussanomat":
www.is.fi##article:not(:has(> article)):has(> a > section:not(:has(.teaser-info-category:has-text(/^(politiikka|kotimaa|taloussanomat)/i)))):remove()

Block related articles shown below an article:

# ... by link,
# example: all that points to links like /urheilu/art-2000012345678.html
www.is.fi##.related-articles > a[href^="/urheilu"]

# ... by title with regex,
# example: titles like "yllättävään tilanteeseen" or "yllättävän kauhea tilanne" are blocked with this:
www.is.fi##.related-articles > a:has(span:has-text(/yllättävä.+ tilan/i))

# ... by whitelisting only allowed title categories,
# example: use non-casesensitive filter for "Politiikka", "Kotimaa", and "Taloussanomat":
www.is.fi##.related-articles > a:not(:has(.related-articles__category:has-text(/^(politiikka|kotimaa|taloussanomat)/i)))

Block articles listed in the side panel, e.g. "Newest" or "Most read":

# ... by link,
# example: all that points to links like /urheilu/art-2000012345678.html
www.is.fi##article:has(> header) > ol > li:has(> a[href^="/urheilu"])

# ... by title with regex,
# example: titles like "yllättävään tilanteeseen" or "yllättävän kauhea tilanne" are blocked with this:
www.is.fi##article:has(> header) > ol > li:has(> a:has(span:has-text(/yllättävä.+ tilan/i)))

Block video articles:

www.is.fi##article:not(:has(> article)):has(> a > section:has(.video-indicator))

Iltalehti

These rules should work for both mobile and desktop browsers.

For all filter rules related to links, please hower your mouse cursor on the article to see to which link it points to. Then use this link to create the block rule.

Block articles from main feed:

# ... by link (sub cagegory):
# We need to use the `:remove()` option so that we can remove those ugly empty article
# containers afterwards.
www.iltalehti.fi##div[class*="-article"]:has( > a[href^="/digitestit"]):remove()

# ... by HTML class representing main category for the article:
# This will block all sub categories that falls under the main category "Urheilu".
www.iltalehti.fi##div[class*="-article"]:has( > a > .category-time > .urheilu):remove()

Block articles listed in the side panel, e.g. "Newest" or "Most read":

# ... by link (sub cagegory):
www.iltalehti.fi##.article-list > .article-container[href^="/digitestit"]

# ... by HTML class representing main category for the article:
# This will block all sub categories that falls under the main category "Urheilu".
www.iltalehti.fi##.article-list > .article-container:has(> .title-container > .category-time > .urheilu)

Block related articles listed below an article:

# ... by link (sub cagegory):
www.iltalehti.fi##.related-articles-list > a[href^="/kilpailulajit"]

# ... by HTML class representing main category for the article:
# This will block all sub categories that falls under the main category "Urheilu".
www.iltalehti.fi##.related-articles-list > a:has(> .title-container > .category-time > .urheilu)

Block recommendations listed below an article:

# ... by link (sub cagegory):
www.iltalehti.fi##.recommendations > .recommendation:has(a[href^="/kilpailulajit"])

# ... by HTML class representing main category for the article:
www.iltalehti.fi##.recommendations > .recommendation:has(> a > .category-time > .urheilu)

Block sticky articles, i.e. those shown on top of the page with a article title only

# ... by link
www.iltalehti.fi##.newsticker > .newsticker-item[href^="/ruoka-artikkelit"]

Block side panel content:

# Use side panel component title:
# example: block "Luetuimmat" and "IL-TV"
www.iltalehti.fi##.card:has(> .block > .article-list-tabs:has(> .article-list-tabs-heading:has-text(/^(luetuimmat|il-tv)/i)))

# Block component asking for news tips:
www.iltalehti.fi##.card:has(> .block > .news-tip)

# Block component showing physical newspaper:
www.iltalehti.fi##.card:has(> .block > .nakoislehti-column-box)

# Block telkku.com component:
www.iltalehti.fi##.card:has(> .block > .telkku-column-embed)

# Block component showing minigames:
www.iltalehti.fi##.card:has(> .block > .pastime-column-embed)

# Block email newletter component:
www.iltalehti.fi##.card:has(> .block > .iltalehti-newsletter-column-embed)

Remove empty article containers after all the blocking rules have removed unwanted content (These might break the website!):

# Remove theme banners from empty article containers
www.iltalehti.fi##.fp-container:not(:has(> div[class*="-article"])):has(> div[class*="theme-banner"])

# Remove empty article containers for third party articles, e.g. kauppalehti
www.iltalehti.fi##.fp-container:not(:has(> div[class*="-article"])):has(> div[class*="alma-embed"])

# Remove empty article containers
www.iltalehti.fi##.fp-container:empty
www.iltalehti.fi##.category-double-article-container:empty
www.iltalehti.fi##.card:empty

Streaming services

YouTube

Block all Shorts:

www.youtube.com##ytd-reel-shelf-renderer:has(#title:has-text(/^shorts/i))
www.youtube.com##ytd-rich-shelf-renderer:has(#title:has-text(/^shorts/i))

Block all Mix playlists:

www.youtube.com##ytd-rich-item-renderer:has(> #content:has(a[title^="Mix - "]))

Block all "For you" videos from search results:

www.youtube.com##ytd-shelf-renderer:has(> #dismissible:has(#title:has-text("For you")))

Social media

Facebook

Block "Suggested" posts:

facebook.com##.html-div:has(> div > div[data-visualcompletion]):has(span:has-text(/^Suggested/))

Block posts from random Facebook pages with "Follow" button:

facebook.com##.html-div:has(> div > div[data-visualcompletion]):has(span:has-text(/^Follow/))

Block "Reels and short videos":

facebook.com##div:has(> div:empty):has(> div[style*="border-radius"]:has(span:has-text(/^Reels and short videos/)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment