8

I want to write a ublock filter to hide a list element that has a certain class and content, while I don't want to hide other list items that don't have this content:

class = "mp-Listing-priority"
content is "Topad"

This is the html code of the item that I want to hide.

<li class="mp-Listing mp-Listing--list-item ">
    <a href="" class="mp-Listing-cover-link experimentStateC"></a>
    <figure class="mp-Listing-image-container"></figure>
    <div class="mp-Listing-content">
        <div class="mp-Listing-group mp-Listing-group--main"></div>
        <div class="mp-Listing-group mp-Listing-group--aside">
            <div class="mp-Listing-group mp-Listing-group--top-block"></div>
            <div class="mp-Listing-group mp-Listing-group--bottom-block">
                <span class="mp-Listing-priority">Topad</span>
                <span class="mp-Listing-seller-link">
                    <a href="https://.../" target="_blank" rel="noopener noreferrer nofollow" class="mp-TextLink ">Visit website</a>
                </span>
            </div>
        </div>
    </div>
</li>

None of the examples below hide the list elements that I want to hide:

##li.mp-Listing--list-item[class="mp-Listing-priority"]
##li.mp-Listing--list-item["Topad"]
  • @Temani Afif, this is not about CSS directly, it's about uBlock! there you can select stuff based on content... please reconsider... – exside Jul 30 '19 at 12:20
  • 1
    I think you could hide that with `www.domain.com##li.mp-Listing--list-item .mp-Listing-priority:has-text(Topad)` not the domain/target in front of the cosmetic filter though, I think uBlock ignores rules without a domain! – exside Jul 30 '19 at 12:21
  • using www.domain.com##li.mp-Listing--list-item .mp-Listing-priority:has-text(Topad) hides the Topad text from each element in the list, instead of hiding the list element as requested. –  Jul 30 '19 at 12:35
  • 2
    what if you try `www.domain.com##li.mp-Listing--list-item:has-text(Topad)` – exside Jul 30 '19 at 12:38

1 Answers1

5

The answer is

##li.mp-Listing--list-item:has-text(Topad)

Thank you exside