Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Add procedural cosmetic operators remove() and upward()#252

Merged
JustOff merged 3 commits intogorhill:masterfrom
hawkeye116477:removeUpward
Jul 24, 2020
Merged

Add procedural cosmetic operators remove() and upward()#252
JustOff merged 3 commits intogorhill:masterfrom
hawkeye116477:removeUpward

Conversation

@hawkeye116477
Copy link
Contributor

@hawkeye116477 hawkeye116477 commented Jul 17, 2020

Fixes #233 and fixes #224. Code is almost original, only changed const to let in for of loop.

2020-07-17_13-35

@JustOff
Copy link
Collaborator

JustOff commented Jul 17, 2020

Thank you, but could you please update the commit to include the original description from gorhill/uBlock@72bb700?

Please use git commit --amend + git push -f to update this PR and not create a new one.

New procedural cosmetic operator: `:remove()`

Related issue:
- gorhill/uBlock#2252

The purpose is to outright remove elements from the
DOM tree. Since `:remove()` is an "action" operator,
it must only be used as a trailing operator (just
like the `:style()` operator).

AdGuard's cosmetic filter syntax `{ remove: true; }`
will be converted to uBO's `:remove()` operator
internally.

***

New procedural cosmetic operator: `:upward(...)`

The purpose is to lookup an ancestor element.

When used with an integer argument, it is synonym of
`:nth-ancestor()`, which will be deprecated and which
will no longer be supported once no longer used in
mainstream filter lists.

Filter lists maintainers must only use `:upward(int)`
instead of `:nth-ancestor(int)` once the new operator
become available in all stable releases of uBO.

`:upward()` can also accept a CSS selector as argument,
in which case the nearest ancestor which matches the
CSS selector will be selected.

Co-authored-by:  gorhill <585534+gorhill@users.noreply.github.com>
@hawkeye116477
Copy link
Contributor Author

@JustOff Done

@JustOff
Copy link
Collaborator

JustOff commented Jul 17, 2020

Thanks, I started using this in my main browser and if nothing unexpected happens I'm going to initiate a release early next week.

@JustOff
Copy link
Collaborator

JustOff commented Jul 17, 2020

It seems that changes to cosmetic-logger.js are not working as expected. I guess we can just exclude them, right?

@hawkeye116477
Copy link
Contributor Author

hawkeye116477 commented Jul 17, 2020

Oops, seems that change was related with gorhill/uBlock@3573b6b#diff-fe57879eb27e2bdc0b78a77743617201. Anyway, should be fixed with latest commit.

@JustOff
Copy link
Collaborator

JustOff commented Jul 17, 2020

Anyway, should be fixed with latest commit.

Yep, it seems it is.

Related discussion:
- gorhill/uBO-Extra#119 (comment)

As an incidental side effect, this may or may not
prevent execution of the content of some inline
script tags.

Co-authored-by:  gorhill <585534+gorhill@users.noreply.github.com>
@JustOff JustOff merged commit 1e61ea1 into gorhill:master Jul 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for ":remove()" Add support for ":nth-ancestor" and ":upward"

2 participants