htmladblock

uBlock: Block outer div by div class of inner


I am trying to block specific div elements with uBlock, but I want to block the full other div by searching for the class name of an inner value.

It looks exactly like that:

<div class="comment-content edited">
    <div class="comment-header">
        <div class="comment-header-info">
            <div class="comment-author">
                <div class="comment-author-info">
                    <div style="font-family: HeadlineFont;">
                        <div class="author-name">Name</div>
                    </div>
                </div>
            </div>
            <div class="comment-description">
                <div style="color: rgb(156, 156, 156);" class="comment-date">for to timer siden <span
                        class="edited-info"> (redigert)</span>
                    <div style="background-color: rgb(44, 44, 44);" class="date-tooltip">8/31/2022, 7:41:59 AM</div>
                </div>
            </div>
        </div>
    </div>
    <div class="comment-message"><span class="">
            <!-- more content-->
        </span></div>
    <div class="comment-footer">
        <!-- more content -->
    </div>
</div>

So I am going to block the entire block of the div-class comment-content edited if the author-name of the div class lower is something.

Is there a smart way to do so?


Solution

  • Try this:

    ##div.comment-content:has(div.author-name:has-text('Name'))
    

    Or you could be even more explicit:

    ##div.comment-content:has(div > div > div > div > div > div.author-name:has-text('Name'))
    

    See here for more information: Procedural cosmetic filters