Giter Club home page Giter Club logo

Comments (7)

mon-jai avatar mon-jai commented on May 28, 2024 2

@anfragment Projects like urlfilter (by AdGuard) and Privaxy have explored and implemented this idea.

The former is also written in Golang and support (part of) ubloack filter syntax. Maybe we can borrow some code from it.

from zen.

Explosion-Scratch avatar Explosion-Scratch commented on May 28, 2024 1

You've just made me realize that cosmetic rules are essentially CSS selectors. That'll simplify things a lot, thank you.

No problem, it removes the need for mutation observers and such. Also event listeners on ad elements referencing nonexistant elements might break things as well.

Might still want to .remove() iframes, embeds, videos, etc. Maybe remove anything with a .src/.href so performance doesn't clog the page.

I think the ideal process would be:

  1. Remove elements server side using DOMParser to select them
  2. Generate stylesheets based on targeted elements as well, if no :style(...) rules are present in the blocking rule than just fill in display: none. You can also generate scripts for things like example.com##+js(nano-sib, /mousemove|click|select/). You might be able to set up some sort of CI to pull these from ublock
  3. Inject the CSS + JS

Some precautions though: Make sure to only mess with the response if it's for a viewable page, not API requests.

from zen.

anfragment avatar anfragment commented on May 28, 2024

I've had some ideas on how to implement this, would be totally possible via injecting some browser-side JS, but we need to polish the network filtering and GUI stuff first. I'll make sure to come back to this in the future.

from zen.

Explosion-Scratch avatar Explosion-Scratch commented on May 28, 2024

So you'd inject JS to remove layout elements and such? Why not just do it via DOM Parsing before response is sent?

from zen.

anfragment avatar anfragment commented on May 28, 2024

Quite a lot of HTML gets rendered by client-side JS frameworks these days. DOM Parsing could do the job for static websites, but I'm afraid we would end up needing a client-side solution anyways.

from zen.

Explosion-Scratch avatar Explosion-Scratch commented on May 28, 2024

Quite a lot of HTML gets rendered by client-side JS frameworks these days. DOM Parsing could do the job for static websites, but I'm afraid we would end up needing a client-side solution anyways.

That's true, a little bit of display: none goes a long way as well.

from zen.

anfragment avatar anfragment commented on May 28, 2024

Quite a lot of HTML gets rendered by client-side JS frameworks these days. DOM Parsing could do the job for static websites, but I'm afraid we would end up needing a client-side solution anyways.

That's true, a little bit of display: none goes a long way as well.

You've just made me realize that cosmetic rules are essentially CSS selectors. That'll simplify things a lot, thank you.

from zen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.