Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jul 24, 2020

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.

Verified

This commit was signed with the committer’s verified signature. The key has expired.
xeho91 Mateusz Kadlubowski
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 join this conversation on GitHub. Already have an account? Sign in to comment
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