uBlock-LLC / uBlock

uBlock: a fast, lightweight, and lean blocker for Chrome, Firefox, and Safari.
https://ublock.org/
GNU General Public License v3.0
8.18k stars 436 forks source link

Expand extended syntax [Important] #1395

Closed davidhedlund closed 2 years ago

davidhedlund commented 9 years ago

List of Local uBlock dynamic filtering

List of Global uBlock dynamic filtering

List of Local uBlock dynamic filtering translated to static filters

List of Global uBlock dynamic filtering translated to static filters

Missing:

Further reading

Snapy commented 9 years ago

Try this ABP page for filter syntax.

chrisaljoudi commented 9 years ago

@davidhedlund The dynamic filtering rules are handled differently from the "static net filtering" (which is what the ABP filter syntax specifies).

Check out the "My Rules" tab in uBlock's preferences to see the textual representation of the dynamic filtering rules.

davidhedlund commented 9 years ago

@chrisaljoudi It is possible to write

||google-analytics.com^$important,third-party but not ||google-analytics.com^$important,third-party --gstatic.com^$important,third-party

gstatic might be a third-party of google-analytics.com. say that "--" above means "noop" which in that example will let gstatic.com to use static net filtering instead of being blocked.

davidhedlund commented 9 years ago

@chrisaljoudi The reason why I want to write rule-like filters is because I want people to have the possibility to subscribe to them. That's not possible with rules, right?

chrisaljoudi commented 9 years ago

@davidhedlund right, it's currently not possible to import/subscribe to external dynamic filtering rules.

In your example, though, I'm a bit confused.

This filter:

||google-analytics.com^$important,third-party

does not affect gstatic.com. Why would you need to "noop" gstatic.com then?

davidhedlund commented 9 years ago

@chrisaljoudi That was just a (bad) example. Please refer to the screenshot in the top of this post. Would it hurt to add "noop" to the extended syntax?

As I see it everything should be in "My filters" (static and dynamic filters). Its simpler that way and there's not really any reason to keep My Rules if you add the requested syntax above.

chrisaljoudi commented 9 years ago

@davidhedlund It's not that it would hurt, I just don't understand what it means.

Let's say we have the following (I used the -- syntax you used as an example):

||google.com^$script
--googleAnalyticsScript.js$script
*AnalyticsScript.js$script

Would google.com/googleAnalyticsScript.js be blocked or not (in the final result)?

chrisaljoudi commented 9 years ago

@davidhedlund Let me see if I can communicate this better:

noop makes sense in dynamic filtering because dynamic filtering occurs as a step before static net filtering. So it just means: "okay, let it through to the second step [which is static net filtering]".

noop doesn't make sense in the context of static net filtering because there are no steps after that.

In other words, by the end of the static net filtering step, one must have either an allow or a block, not a noop.

davidhedlund commented 9 years ago

@chrisaljoudi I suggest that you add noop syntax that can be used to write filter. Just make uBlock to start by only execute dynamic filters (like noop) and then start over again to only execute static filters.

I hope I'm clear enough even if my native language is Swedish. Do you understand me?

chrisaljoudi commented 9 years ago

@davidhedlund I'm sorry, I'm afraid I don't.

How does a noop filter in static net filtering (as I understand it from your description) differ from an exception filter?

davidhedlund commented 9 years ago

@chrisaljoudi I suggested that noop (!! might be better as Adblock Plus will read ! as comment), global, and all, can be added to My filters. The title for filters is My filters not My static filters, so there is room to expand that section to use dynamic filters too.

1: I suggest that you change the My rules syntax to filter-based syntax, example: Changing www.domain.tld * noop to !!domain.tld. It's a win-win even if you decide to stay here and not want to proceed with the next step. 2: Merge My rules to My filters and remove My rules. Then make sure that uBlock uses My filters by executing dynamic filters before static filters.

davidhedlund commented 9 years ago

List of uBlock dynamic filtering translated to static filters

chrisaljoudi commented 9 years ago

@davidhedlund I get what you're saying now.

I'll have to give this some thought, because it breaks default-deny in some ways.

davidhedlund commented 9 years ago

@chrisaljoudi Is all: ||domain.tld^ <--------------------------------- Correct?

chrisaljoudi commented 9 years ago

@davidhedlund nope. More like:

*$domain=domain.tld
davidhedlund commented 9 years ago

@chrisaljoudi Thank you! I added that to the top of the post as reference.

chrisaljoudi commented 9 years ago

@davidhedlund I believe so; that would block all requests when on a page from the domain fsf.org.

davidhedlund commented 9 years ago

@chrisaljoudi This is good. I removed the "all" problem from this post.

davidhedlund commented 9 years ago

@chrisaljoudi What about global?

chrisaljoudi commented 9 years ago

@davidhedlund what about "global"? What's an example?

davidhedlund commented 9 years ago

@chrisaljoudi *$domain=github.com is for "all local", how would that be written for "all global"?

chrisaljoudi commented 9 years ago

@davidhedlund if you mean matching every request globally:

*
davidhedlund commented 9 years ago

@chrisaljoudi so ||* blocks everything?

chrisaljoudi commented 9 years ago

@davidhedlund * matches everything, yes.

davidhedlund commented 9 years ago

@chrisaljoudi To take a better example:

Local: ||github.com^$third-party,script Global: ||*^$third-party,script

Is Global written correct?

chrisaljoudi commented 9 years ago

@davidhedlund it would be:

*$third-party,script
davidhedlund commented 9 years ago

@chrisaljoudi Perhaps we want to replace ||twitter.com^$important,third-party with *$important,third-party and explain that it is equivalent to global block of 3rd-party scripts in https://github.com/chrisaljoudi/uBlock/wiki/Filter-syntax-extensions#extended-syntax

What do you think about it?

davidhedlund commented 9 years ago

@chrisaljoudi all local for github.com is *$domain=github.com. Is all global equivalent to $domain=*?

chrisaljoudi commented 9 years ago

@davidhedlund yes, but $domain=* is just like not having it at all.

davidhedlund commented 9 years ago

@chrisaljoudi when I add $domain=* (or *$domain=*) I can see everything in fsf.org but when I select all global less content of the page is showed to me. This means that the static filters $domain=* or *$domain=* is not equivalent to the dynamic filter * * * block (all global).

davidhedlund commented 9 years ago

@chrisaljoudi Please help me proof-read these lists:

List of Local uBlock dynamic filtering

List of Global uBlock dynamic filtering

List of Local uBlock dynamic filtering translated to static filters

List of Global uBlock dynamic filtering translated to static filters

gwarser commented 9 years ago

I think these should be rewritten:

images: ||github.com^$image
3rd-party: ||github.com^$third-party
3rd-party scripts: ||github.com^$third-party,script
3rd-party frames: ||github.com^$subdocument

in this format:

*$domain=github.com,image
...

because you don't want to block github.com/images.jpg but all images when browsing github.com

not sure about this:

inline scripts: ||github.com^$inline-script

and this:

1st-party scripts: ||github.com^$script

but might be

||github.com^$domain=github.com,script or ||github.com^$~third-party,script

because you want to block scripts from github when you are on github

seanrand commented 9 years ago

Sorry, I don't understand the point of this exercise. Why are you trying to rewrite dynamic filtering rules as static filtering rules in the first place?

If

because I want people to have the possibility to subscribe to them

is the only reason, wouldn't it make more sense to define a format for sharing dynamic filter lists and adding a way to subscribe to them similar to the static 3rd party filters?

[uBlock xx]
! Title: Example of a uBlock dynamic filter subscription file
! Last modified: 19 May 2015 19:11 UTC
! Expires: 4 days (update frequency)
* * 3p-frame block
* * 3p-script block
wikipedia.org wikimedia.org * noop
www.dropbox.com dropboxstatic.com * noop
www.facebook.com akamaihd.net * noop
! etc etc etc

And if that's the only reason, I doubt that being able to subscribe to dynamic filtering rules would be very useful anyway.

For people who use default-deny, the dynamic filters are mostly a very short, personal selection of frequently visited sites. You'd have a lot of maintenance overhead to provide people with a dynamic filtering list to subscribe to that includes all their favourite websites in order to be of any use to them.

davidhedlund commented 9 years ago

@chrisaljoudi Can you please validate the current list https://github.com/chrisaljoudi/uBlock/issues/1395#issue-78057363?

ghost commented 9 years ago

It's worth noting that you can create static filters from the logger in uBlock Origin now. https://github.com/gorhill/uBlock/releases - See 0.9.8.7 https://github.com/gorhill/uBlock/commit/48f47a6849729beb73f1bd62d19d1b28f562356d https://github.com/gorhill/uBlock/commit/91cb61ce9cb61b0fa82780d2ba12a42b2293c169 https://github.com/gorhill/uBlock/commit/056a760dc43c5c913ef03f2c883e6538819659f0

davidhedlund commented 9 years ago

@hotdogman Thx.