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

Element Hiding Support for Filter Lists #14

Open
cretz opened this Issue Sep 6, 2017 · 1 comment

Comments

1 participant
@cretz
Owner

cretz commented Sep 6, 2017

This needs to be done via an immutable web mutation observer. May require some IPC back home w/ a class list or something.

@cretz cretz added the enhancement label Sep 6, 2017

@cretz

This comment has been minimized.

Show comment
Hide comment
@cretz

cretz Oct 2, 2017

Owner

Ok, here's how I will do it if I figure it's worth the effort:

  • When parsing rules, just parse the element hiding part (not too hard per https://www.w3.org/TR/selectors/ and https://adblockplus.org/filters#elemhide)
  • When applied, make a global class for the rules (and the quick lookup thereof) then either...
    • Share a copy of the class with http://doc.qt.io/qt-5/qsharedmemory.html
    • Build a fast and quality encompassing way to IPC all of the needed data about an element to check whether it should be blocked
  • Inject a non-overridable MutationObserver when a frame is loaded (some of the scaffolding is already there)
  • Either...
    • Use the shared memory bytes to cast to known class and do lookup for each node coming through the mutation observer. This needs to be fast, so we have to be careful to make sure the matching work is fast and only asks things of the node as it needs them.
    • Do the IPC data sending necessary to ask the main process whether the elements are hide-able
  • On each one found, inject CSS to do the proper hiding of the element (not sure if style tag or how to do this just yet to make sure we have priority)

Be careful not to use the uBlock code to learn from, it is GPL.

Owner

cretz commented Oct 2, 2017

Ok, here's how I will do it if I figure it's worth the effort:

  • When parsing rules, just parse the element hiding part (not too hard per https://www.w3.org/TR/selectors/ and https://adblockplus.org/filters#elemhide)
  • When applied, make a global class for the rules (and the quick lookup thereof) then either...
    • Share a copy of the class with http://doc.qt.io/qt-5/qsharedmemory.html
    • Build a fast and quality encompassing way to IPC all of the needed data about an element to check whether it should be blocked
  • Inject a non-overridable MutationObserver when a frame is loaded (some of the scaffolding is already there)
  • Either...
    • Use the shared memory bytes to cast to known class and do lookup for each node coming through the mutation observer. This needs to be fast, so we have to be careful to make sure the matching work is fast and only asks things of the node as it needs them.
    • Do the IPC data sending necessary to ask the main process whether the elements are hide-able
  • On each one found, inject CSS to do the proper hiding of the element (not sure if style tag or how to do this just yet to make sure we have priority)

Be careful not to use the uBlock code to learn from, it is GPL.

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