doogie
doogie copied to clipboard
Element Hiding Support for Filter Lists
This needs to be done via an immutable web mutation observer. May require some IPC back home w/ a class list or something.
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
MutationObserverwhen 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.