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-class "stay" doesn't prevent re-injection #2203

Closed
8 tasks done
MasterKia opened this issue Aug 8, 2022 · 14 comments
Closed
8 tasks done

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

MasterKia opened this issue Aug 8, 2022 · 14 comments
Labels
declined declined

Comments

@MasterKia
Copy link
Member

MasterKia commented Aug 8, 2022

Prerequisites

I tried to reproduce the issue when...

  • uBO is the only extension
  • uBO with default lists/settings
  • using a new, unmodified browser profile

Description

Maybe related: #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:

remove-class.mp4

uBlock Origin version

1.43.0

Browser name and version

Firefox 103.0.1

Operating System and version

Fedora 36 KDE

@krystian3w
Copy link

krystian3w commented Aug 8, 2022

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: FiltersHeroes/PolishAnnoyanceFilters#2667 (comment)

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

krystian3w referenced this issue in FiltersHeroes/PolishAnnoyanceFilters Aug 8, 2022
#2667 - strona brzydko przywraca tag style, potrzebujemy lepszy skryptlet lub konserwacja tych dwóch.

Opcjonalnie bug w uBo z wykrywaniem zmian w drzewie dom/nodzie.
@gwarser
Copy link

gwarser commented Aug 8, 2022

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
Copy link
Member Author

MasterKia commented Aug 8, 2022

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
Copy link

krystian3w commented Aug 8, 2022

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

@MasterKia
Copy link
Member Author

Video added.

@MasterKia
Copy link
Member Author

MasterKia commented Aug 8, 2022

@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
Copy link

krystian3w commented Aug 8, 2022

So also no implemented abort injection correct.

@gwarser
Copy link

gwarser commented Aug 8, 2022

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

@MasterKia
Copy link
Member Author

MasterKia commented Aug 8, 2022

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
Copy link
Member Author

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

Any help is appreciated.

@gwarser
Copy link

gwarser commented Aug 8, 2022

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
Copy link
Member Author

MasterKia commented Aug 8, 2022

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
Copy link

gwarser commented Aug 8, 2022

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

@gorhill
Copy link
Member

gorhill commented Aug 10, 2022

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.

@gorhill gorhill closed this as completed Aug 10, 2022
@gorhill gorhill added the declined declined label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
declined declined
Projects
None yet
Development

No branches or pull requests

4 participants