Skip to content

Loading…

[Chromium] Element picker (nth-child usage) #637

Closed
rsdsoft opened this Issue · 7 comments

3 participants

@rsdsoft

Element picker is much more poor than in Adguard. Could you use similar constructions to hide elements?
riper.am###portal-body > TBODY > TR > TD:nth-child(2) > DIV.forumbg:nth-child(6)

@rsdsoft rsdsoft changed the title from Element picker (nth-child usage) to [Chromium] Element picker (nth-child usage)
@my-password-is-password

nth-child works to hide elements.

If you go to riper.am and run document.querySelectorAll('#portal-body > TBODY > TR > TD:nth-child(2) > DIV') in the console. There is no .forumbg, looks like it changed to .forabg.

Also for DIV.forabg i think you need to use :nth-of-type() instead of :nth-child()

For example, add riper.am###portal-body > TBODY > TR > TD:nth-child(2) > DIV.forabg:nth-of-type(4) to your filters in uBlock and see the poll section is hidden on riper.am.

Not sure what you want to hide though. I was guessing a .forabg section.

@gorhill

Could you use similar constructions to hide elements?

Yes. Whatever is a valid CSS rule can be used. Why not just try it in the element picker? It will show you live the effect on the page as you type. (Don't enter the riper.am prefix in the element picker text area, it is implicit).

By the way, uBlock is not offering you the ability to create that filter because there is no match on the page, so the filter accomplish nothing. Looks like a good thing to me to not let you create a noop filter.

@gorhill gorhill closed this
@rsdsoft

Seems you did not understand what I mean. I talk about element picker. If you try to select one of the box on rimer.am for example it will select all similar and hide all of them (but I want to hide one box which I select exactly). It could not use nth-child as Adguard element picker. So I need to use adguard element picker then copy generated text rules to uBlock rules.

@gorhill

I understood very well. You did not understand.

I repeat: uBlock will apply whatever CSS rule you give it, nth-child included.

If it did not "work", it's because no element on the page matches you CSS rule. It is valid CSS, but it matches nothing. Nothing matches .forumbg on the page, and Adguard won't magically make sense of this either. And if ever it was a typo and you meant .forabg, then nothing matches div.forabg:nth-child(6) on the page, as the DOM element at the 6th position is a br node, not a div node.

You should try again with the mindset that it does work, and if it seems it doesn't, it's because you have a flawed CSS selector. Any rule given to uBlock goes directly to document.querySelectorAll, so saying "uBlock does not support [CSS rule placeholder]" is same as saying "document.querySelectorAll() does not support [CSS rule placeholder]"

What would be constructive is that you provide a screenshot and tell us exactly what you want removed from the page, then I will show you how to use the element picker to accomplish this.

@gorhill

Trying to guess here... Isn't what you were trying to remove:

riper.am###portal-body > tbody > tr > td > .forabg:nth-of-type(3)

?

@rsdsoft

Yes. And other boxes one by one using elemnt picker only. But element picker selects all similar divs after click on one of them (adguard element picker select and remove the box which I clicked only).

@gorhill

OK, I saw the light, you're right, I didn't get it.

I focused on "doesn't support nth-child" (which it does support), while what you want is that uBlock generates the proper extra CSS selector(s) to have a more narrow selection at the end after you click on an element on the page.

@gorhill gorhill reopened this
@gorhill gorhill added a commit that closed this issue
@gorhill gorhill this fixes #637 9467e7f
@gorhill gorhill closed this in 9467e7f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.