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

Scriptlets remove-node-text.js and trusted-replace-node-text.js destroy DOM elements #3492

Closed
9 tasks done
Torbins opened this issue Dec 19, 2024 · 5 comments
Closed
9 tasks done
Labels
wontfix won't be addressed

Comments

@Torbins
Copy link

Torbins commented Dec 19, 2024

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is NOT a YouTube, Facebook or Twitch report. These sites MUST be reported by clicking their respective links.
  • This is not a support issue or a question. For support, questions, or help, visit /r/uBlockOrigin.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • uBO uses default lists and settings.
  • using a new, unmodified browser profile.

Description

For example we have part of HTML:
<p><span class="regin0.xxxx">Please contact us at [email protected] if you see this on another site.</span><a name="L6"></a> 「Hey, Jig, Shiasha-san. Good work」<span class="eloun0.xxxx">Several dragons looked at the human girl in amazement.</span></p>
And we have following rule:
example.com##+js(replace-node-text,p,「,- )

A specific URL where the issue occurs.

https://www.foxteller.com/novel/643/33/the-witch-and-the-mercenary/033

Steps to Reproduce

  1. Add rule above to the list of custom rules
  2. Reload web page

Expected behavior

HTML becomes like this:
<p><span class="regin0.xxxx">Please contact us at [email protected] if you see this on another site.</span><a name="L6"></a> - Hey, Jig, Shiasha-san. Good work」<span class="eloun0.xxxx">Several dragons looked at the human girl in amazement.</span></p>

Actual behavior

HTML becomes like this:
<p>Please contact us at [email protected] if you see this on another site. - Hey, Jig, Shiasha-san. Good work」Several dragons looked at the human girl in amazement.</p>

uBO version

1.61.2

Browser name and version

Firefox 133.0.3

Operating System and version

Windows 11 24H2

@krystian3w
Copy link

krystian3w commented Dec 20, 2024

Seems fine for remove-node-text, p will be empty.

IDK possibly repair for trusted-replace-node-text, fails on #text as node hook (even I tried use loop).

@gwarser
Copy link

gwarser commented Dec 20, 2024

Try using #text as node name.

(Cannot test on your example - racing.)

@gorhill
Copy link
Member

gorhill commented Dec 22, 2024

This is the expected behavior: replace the textContent of an element (<p> in your case) is going to remove everything under p and replace with a #text node in which instances of are replaced with -.

Additionally, the text on that page is added dynamically, whereas trusted-replace-node-text is active only until the DOMContentLoaded is received.

In any case, even the following filter accomplishes nothing on my side:

foxteller.com##+js(replace-node-text, #text, 「, -, stay, 1, quitAfter, 30000)

How did you make it work at all? I can't even cause the breakage.

@krystian3w
Copy link

@gorhill
Copy link
Member

gorhill commented Dec 22, 2024

Seems still fails

Ok it's because trusted-replace-note-text doesn't look deep into mutations, only superficially. The primary purpose of trusted-replace-node-text was not to comprehensively replace text on a web page, this is at most a side effect.

For the purpose of replacing text on a web page, it's best to add a procedural cosmetic replace-text() operator -- but this would require concept of trusted source for procedural cosmetic filters, and there is no framework for this at this point, and this would be unrelated to the issue here.

Closing as wontfix, the trusted-replace-node-text scriptlet works as expected, according to its intended limitations. If uBO's filter list maintainers think those limitations should be revised according to real world cases, I will reconsider.

@gorhill gorhill closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2024
@gorhill gorhill added the wontfix won't be addressed label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix won't be addressed
Projects
None yet
Development

No branches or pull requests

4 participants