You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何编写UBlock过滤规则,隐藏含指定子元素内容的目标列表项?

Correct uBlock Origin Filter to Hide Targeted List Items

Hey there! Let's get that uBlock filter working for you. The problem with your initial attempts is that you were trying to target attributes or text directly on the <li> element, but the mp-Listing-priority class and "Topad" text belong to a child <span>—not the list item itself.

The Working Filter Rule

Here's the exact filter you need to hide only those <li> elements containing the specific "Topad" span:

li.mp-Listing--list-item:has(.mp-Listing-priority:contains("Topad"))

If you want to keep it concise (since the class is specific enough), this shorter version also works:

mp-Listing--list-item:has(.mp-Listing-priority:contains("Topad"))

Why Your Original Rules Failed

Let's break down what went wrong with your initial attempts:

  • ##li.mp-Listing--list-item[class="mp-Listing-priority"]: This rule looks for <li> elements that have the mp-Listing-priority class, but that class is assigned to the child <span>, not the list item itself.
  • ##li.mp-Listing--list-item["Topad"]: This syntax is invalid for uBlock filters. You can't target text content on a parent element directly like this—you need to use the :contains() pseudo-class on the specific child element that holds the text.

Optional: More Precise Nesting (For Edge Cases)

If you're worried about accidental matches with other elements on the page, you can lock in the exact nesting structure from your HTML:

li.mp-Listing.mp-Listing--list-item:has(.mp-Listing-content .mp-Listing-group--aside .mp-Listing-group--bottom-block .mp-Listing-priority:contains("Topad"))

This ensures only list items with that exact hierarchy of child elements get hidden.

Just a quick note: Make sure your uBlock Origin is updated to a recent version—has() and contains() support has been stable for a while, but an update ensures you're running the latest filtering capabilities.

内容的提问来源于stack exchange,提问作者user11857424

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 06:27:41