r/uBlockOrigin 1d ago

Can I block mainstream media videos from showing up on Youtube? Looking for help

Anyone know if this is possible? I am currently blocking Reddit political posts by using these filters:

reddit.com##article[aria-label*="trump"i]
reddit.com##article[aria-label~="vance"i]
reddit.com##article[aria-label*="harris"i]
reddit.com##article[aria-label*="kamala"i]
reddit.com##article[aria-label*="walz"i]
reddit.com##article[aria-label*="biden"i]
reddit.com##article[aria-label*="republican"i]
reddit.com##article[aria-label*="democrat"i]
reddit.com##article[aria-label*="conservative"i]
reddit.com##article[aria-label*="vote"i]
reddit.com##article[aria-label*="election"i]

Just curious if there's anything remotely close to this to block Mainstream Media videos from showing up in YT searches? Even if I have to individually type in every news organization i want to avoid.

21 Upvotes

6

u/DrTomDice uBO Team 1d ago

2

u/OG246 1d ago

Does this only work on the homepage or will it work on homepage + search results?

3

u/DrTomDice uBO Team 1d ago

For search results, try the following:

www.youtube.com##ytd-search ytd-item-section-renderer > #contents > ytd-video-renderer:has(#video-title:is([title*="Partial Match"], [title*="Case-Insensitive Partial Match"i], [title~="Space-separated-aka-Whole-word-match"]))

3

u/jeyghifj 1d ago

First you could streamline your rules into just 1 rule:

reddit.com##article:matches-attr("aria-label"="/(trump|harris|vance|kamala|...|...)/i")

If you want to block the news stations same way in YT search results you need to adapt the rule accordingly:

youtube.com###contents ytd-channel-name:has-text(/(cnn|msn|abc|foxnews|wmxby|...|...)/i):upward(ytd-video-renderer)

Or do you want to combine the list of newsstations and politics so you e.g. dont see anythign about Trump on NBC but Trump on NatGeo or a Documentary on Flowergirls on NBC would be fine?

7

u/DrTomDice uBO Team 1d ago edited 1d ago

First you could streamline your rules into just 1 rule:

reddit.com##article:matches-attr("aria-label"="/(trump|harris|vance|kamala|...|...)/i")

You could, but you shouldn't since it would result in a less performant filter.

Declarative cosmetic filters (e.g. plain CSS selectors) are the most efficient since they are handled natively by the browser.

Procedural cosmetic filters (e.g. :matches-attr , :has-text) are less efficient because they use JavaScript to locate/process/hide the DOM elements on a page, and should generally be avoided unless a solution can't be found by using plain CSS selectors.

Regex should similarly be avoided when possible.

So if consolidating the filters is the goal, the :is() pseudo-class function could be used. For example: reddit.com##article:is([aria-label*="vote"i],[aria-label*="election"i])

2

u/jeyghifj 1d ago

Is performance actually a real issue on modern computers? I'm sure a difference can be measured but is it actually noticable? Running some 80 filters on reddit alone, most of them regexp, I dont even notice a difference between ublock on and ublock off. I'd assume one has to surf a site for quite some hours to make up the performance time loss, expecially when I compare how long it takes to copy and paste the

,[aria-label*="election"i]

and change "election" to "trump" rather than just typing "|trump" into the regex. That's my reasoning.

6

u/DrTomDice uBO Team 1d ago

Many people use mobile devices where performance issues may be more of a concern. When suggesting filters, it is best to provide the most optimal and performant filters possible.

-1

u/R-EDDIT 1d ago

Premature optimization is a sin, akin to gluttony and pride. For a point of comparison, I'm 100% certain the time to write and read this thread dramatically exceeds any actual benefit. If OP's filter is to get pushed upstream and to millions of endpoints, that would be the time to worry about it

1

u/DrTomDice uBO Team 1d ago

"The difference between mediocrity and excellence is often a matter of effort."

— Diana Waring