4 ms·
It's especially useful for blocking ads or unwanted elements of a website that has cryptic and ever-changing IDs and classes. With the :has() selector, you can
by beltsazar 4y ago
It's especially useful for blocking ads or unwanted elements of a website that has cryptic and ever-changing IDs and classes. With the :has() selector, you can now block an element by its structure, instead of IDs or classes. Some of my personal uBlock filters that might be useful for others:
! Hide question suggestions
www.quora.com##div.qu-borderAll:has(div:has-text(/^Questions for you$/))
! Hide space suggestions
www.quora.com##div.qu-borderAll:has(div:has-text(/^Discover New Spaces$/))
! Hide 1) left nav bar, 2) footer (clap, comment), 3) right side bar
medium.com##div:has(> nav)
medium.com##div:has(> div:has(> article)) ~ div:last-child
medium.com##div:has(> div:has(> div:has(> div:has(> a[href^="https://help.medium.com"]))))
! Hide non-relevant seach results
www.youtube.com##ytd-search ytd-shelf-renderer:has(h2:has-text(People also watched))
www.youtube.com##ytd-search ytd-shelf-renderer:has(h2:has-text(For you))
www.youtube.com##ytd-search ytd-shelf-renderer:has(h2:has-text(Previously watched))
www.youtube.com##ytd-search ytd-shelf-renderer:has(h2:has-text(Results for similar searches))
www.youtube.com##ytd-search ytd-shelf-renderer:has(h2:has-text(New for you))
! Hide unused buttons (useful for vertical monitors)
www.youtube.com##ytd-toggle-button-renderer:has(yt-formatted-string:has-text(Dislike))
www.youtube.com##ytd-button-renderer:has(yt-formatted-string:has-text(Share))
www.youtube.com##ytd-button-renderer:has(yt-formatted-string:has-text(Thanks))
www.youtube.com##ytd-button-renderer:has(yt-formatted-string:has-text(Clip))
- deleted 4y ago[deleted]
- ketzu 4y agoI used ublock origin for removing recommendations and trending topics on sites like twitter, but it never occured to me how easy I can create them using has().
- azeirah 4y agoIs that :has-text psuedoselector a UBlock-specific feature? I can't find anything on it, I would love to have that in regular css
- js2 4y agoIt looks like it: https://github.com/gorhill/uBlock/blob/72bb89495ba0928042b8c0fe22ee57f6e955ca90/src/js/html-filtering.js#L236 https://github.com/gorhill/uBlock/blob/72bb89495ba0928042b8c... https://github.com/gorhill/uBlock/blob/72bb89495ba0928042b8c0fe22ee57f6e955ca90/src/js/html-filtering.js#L59 https://github.com/gorhill/uBlock/blob/72bb89495ba0928042b8c...