uBlockOrigin / uBlock-issues

This is the community-maintained issue tracker for uBlock Origin
https://github.com/gorhill/uBlock
924 stars 77 forks source link

remove-class "stay" doesn't prevent re-injection #2203

Closed MasterKia closed 2 years ago

MasterKia commented 2 years ago

Prerequisites

I tried to reproduce the issue when...

Description

Maybe related: https://github.com/uBlockOrigin/uBlock-issues/issues/1445

remove-class "stay": This tells the scriplet to stay and act on DOM changes, while the default behavior is to act only once when the document becomes interactive.

A specific URL where the issue occurs

soft98.ir

Steps to Reproduce

0- Preferably disable uBO Quick-Fixes to prevent interference 1- Go to soft98.ir 2- Open inspect element 3- Add soft98.ir##+js(rc, clean, *, stay) to My filters. 4- Refresh the page. 5- The "clean" class gets removed by uBO but is instantly injected again by site.

Expected behavior

uBO should abort attempts to re-inject classes. Also it's preferable if uBO could pretend that the re-injection was successful.

Actual behavior

If the site can re-inject classes then the purpose of remove-class "stay" is defeated entirely. See:

https://user-images.githubusercontent.com/17685483/183411504-22ac04d2-8aae-40e4-a4c9-f1b6d175f57f.mp4

uBlock Origin version

1.43.0

Browser name and version

Firefox 103.0.1

Operating System and version

Fedora 36 KDE

krystian3w commented 2 years ago

File.io no longer host demo/image/video (GitHub like MP4 with any codecs).

Form Polish demo you can also try kill pop-up to select radio station by ra instead aeld: https://github.com/FiltersHeroes/PolishAnnoyanceFilters/issues/2667#issuecomment-1186604538

Also in the past I found war with re-add class/attributes so page blink/jumps as long to delete filter.

gwarser commented 2 years ago

Video does not exists. I cannot find .clean on the page. Did you tried without the * selector? It finds nearly 1k nodes to filter - slow.

MasterKia commented 2 years ago

I cannot find .clean on the page.

For example look for <header id="header" and check its class.

Did you tried without the * selector?

Same result. soft98.ir##+js(rc, clean, , stay)

krystian3w commented 2 years ago

Can you check how works this in AdGuard, his scriptlet support loop/MutationObserver without parameters.

MasterKia commented 2 years ago

Video added.

MasterKia commented 2 years ago

@krystian3w I tested that filter in AdGuard on Ungoogled Chrmoium, same behavior as the video. soft98.ir##+js(rc, clean, , stay)

The only difference I noticed is that AdGuard seems to prevent the re-injection for a few seconds.

krystian3w commented 2 years ago

So also no implemented abort injection correct.

gwarser commented 2 years ago

There is no feature to prevent reinjection. You will need to find the code responsible for this and block it some other way.

MasterKia commented 2 years ago

There is no feature to prevent reinjection.

The site (used to?) have ad re-insertion. In my experience with this site, ##.ads didn't work because of re-injection but ##.ads:remove() was effective against the re-injection. :remove() and remove-class.js seem to do the same thing so there should be a way to prevent re-injection.

:remove() action operator, instruct to remove elements from the DOM tree, instead of just hiding them.

remove-class.js Removes classes from DOM tree node(s)

MasterKia commented 2 years ago

Find the code responsible for this and block it some other way.

Any help is appreciated.

gwarser commented 2 years ago

I'm talking about the rc scriptlet itself. It was designed that way to remove classes added after delay, after page was loaded, not to fight against page script reinserting it back.

MasterKia commented 2 years ago

What's the fundamental back-end difference between :remove() and remove-class.js other than "to remove classes added after delay, after page was loaded"?

Because :remove() seems to be invulnerable to class re-injection but rc.js isn't.

gwarser commented 2 years ago

It's just coincidence. Probably, page script fails when it cannot find the element on which it want to work.

gorhill commented 2 years ago

Whatever piles of code I would throw at uBO (while having to keep maintaining it forever) would be pointless given that the site you are giving as an example is bent on working around whatever uBO does. So I prefer to decline given that the feature is meant to address one specific anti-blocker feature at that one specific site; all work which would become pointless as soon as the site works around it.