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

Remove string in an element's child text with remove-node-text scriptlet #397

Open
piquark6046 opened this issue Jan 9, 2024 · 3 comments
Assignees

Comments

@piquark6046
Copy link
Member

Sometime a filter maintainer needs to remove a string in an element's child text.

<div id="root">
  REMOVE_THIS_STRING
  <div id="login">
  <div id="stats">
</div>

For a real case, a leftover created by AdGuard CoreLibs-based program is not removed by the remove-node-text scriptlet.

https://zdnet.co.kr/view/?no=20231026135022

Screenshot

Screenshot from 2024-01-02 23-48-47

Before you test the real case, please add the following filter:

zdnet.co.kr#@$#body > div[id^="A1_"][style*="height:"] ~ #wrap { margin-top: -1.5em !important; }
@AdamWr
Copy link
Member

AdamWr commented Jan 9, 2024

You can use #text as a nodeName in remove-node-text, for example something like:

zdnet.co.kr#%#//scriptlet('remove-node-text', '#text', 'Blocked by AdGuard')

Or do you mean that you would like to have something like selector > #text?

@piquark6046
Copy link
Member Author

piquark6046 commented Jan 9, 2024

I did not test with #text as a second parameter.
To avoid an incorrect blocking, I think that selector > #text is better.

By the way, Is using the #text as a second parameter in remove-node-text scriptlet Adguard scriptlet's own feature?

@AdamWr
Copy link
Member

AdamWr commented Jan 9, 2024

By the way, Is using the #text as a second parameter in remove-node-text scriptlet Adguard scriptlet's own feature?

I don't think so.
For text nodes, the nodeName returns #text - https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeName, so it's rather not an own feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants