Page 1 of 3

[Done] Site-specific filters

Posted: Mon Dec 15, 2008 8:22 am
by Wladimir Palant
This feature is requested from time to time: making sure a filter applies only on some sites. So here a proposal on how this could be implemented:

foo.com/ad$domain=foo.com|bar.com|~baz.bar.com

This will block anything matching "foo.com/ad" on www.foo.com or www.bar.com but not on baz.bar.com and not on www.baz.com.

Frames would be handled the same as with $third-party (or element hiding rules): if the site contains frames, the relevant domain is the domain of the frame the element is in, not the domain of the top page. That's less obvious to the user, to compensate the composer should have a "Restrict to domain" checkbox under "First/third-party only", if checked you can edit the domain in a text field (pre-filled with the current domain minus "www.").

I would like to follow the syntax of element hiding rules but comma is already reserved as an option separator which is too bad.

Opinions? Suggestions?

Posted: Mon Dec 15, 2008 11:21 am
by fanboy
I'd prefer an new addon (maybe seperate the element hider), that filters javascript, ability to stop javascript functions from loading without whitelisting.

This would be more benefit, better than a site-specific filter feature, stops these hacks attempting to detect adp+.

Posted: Mon Dec 15, 2008 12:09 pm
by Wladimir Palant
Fanboy, that would also require a far larger effort (not to mention that I don't have any good ideas on how this would work). What I propose here can be even implemented in Adblock Plus 1.0.1 - it is fairly straightforward now that we have $third-party. Really, "but I would rather have a pony" isn't helpful.

Posted: Mon Dec 15, 2008 2:57 pm
by Dr. Evil
I think this would be great, especially for whitelists.

But maybe some spaces could improve readability?

Code: Select all

example.org/someads/* on *.example.com or *.example.net
@@example.org/someads/*$object_subrequest on foo.example.net
(Spaces have been forbidden since the old adblock, but with the filters stored in patterns.ini I don't see a problem in breaking this convention...)

Posted: Mon Dec 15, 2008 3:08 pm
by Wladimir Palant
Spaces are not a problem (comments have spaces, as do element hiding rules in the raw CSS part). Only reason they are still being removed - it helps recognizing identical filters as actually identical.

But I wouldn't want to introduce an entirely new syntax (and especially a language-dependent one). We already have options to extend the syntax, I would rather use them.

Posted: Mon Dec 15, 2008 3:39 pm
by rick752
The whole idea sounds great, Wladimir. :D

Looking for to its implementation. That syntax works for me.

Re: Opinions requested: Site-specific filters

Posted: Mon Dec 15, 2008 4:00 pm
by Adblock Plus Fan
Wladimir Palant wrote:|~baz.bar.com
This is an excellent idea Wladimir. This kind of pseudo whitelisting is even better normal whitelisting.
With this kind of capability, small sites will no longer be able to take otherwise good filters as hostage. And we won't have to give them privileges of having real whitelists.

Posted: Mon Dec 15, 2008 4:51 pm
by rick752
Actually, a whitelisting would not even be necessary as you could just add "not" domains to the offending false-positive rule.

Code: Select all

google-analytics$domain=~a.com|~b.com|~c.com
Wouldn't this work as a general blocking rule but with its own built-in domain exceptions, Wladimir?

Posted: Mon Dec 15, 2008 4:56 pm
by Wladimir Palant
@Rick: Yes, that was the idea that you could use it like this.

Posted: Mon Dec 15, 2008 5:01 pm
by rick752
That is AWESOME, Wladimir!
:D

Posted: Mon Dec 15, 2008 6:07 pm
by Adblock Plus Fan
Dr. Evil wrote:I think this would be great, especially for whitelists.
Indeed, especially for users who have the filter
*$third-party,script
When adding whitelists for broken sites, this restriction capability makes ABP clearly the best tool to block 3rd party scripts now.

rick752 wrote:Actually, a whitelisting would not even be necessary
Yep that's what I meant Rick, you can pretty much clear all of your real whitelists from Easylist now and leave them entirely to users. No more complaints from them :P

Posted: Tue Dec 16, 2008 1:34 am
by Dipole Moment
Wladimir Palant wrote:Spaces are not a problem (comments have spaces, as do element hiding rules in the raw CSS part). Only reason they are still being removed - it helps recognizing identical filters as actually identical.

But I wouldn't want to introduce an entirely new syntax (and especially a language-dependent one). We already have options to extend the syntax, I would rather use them.
I think it's probably necessary at this point to devise a proper generalization of the filter syntax, rather than make a series of ad-hoc changes that could become cumbersome later on. I agree DE's suggestion is too language-specific, but it still seems rather awkward to cram all this into a $tag.

Even if it can't all get implemented at one go, what is needed is a syntax that can accommodate
  • match-url vs match-domain perhaps something like {foo.bar} vs foo.bar
  • page-restricted application as above eg

    Code: Select all

    {foo.org} || /bar.asp$/ >> /quux.js$/
  • future content-filtering (and modifying?) capability. This is a bit trickier given the potential for truly mammoth filters. Long-string arguments should be well-distinguished and probably kept to the end for readability's sake.

Posted: Tue Dec 16, 2008 1:38 am
by Dipole Moment
Obviously I meant foo.bar vs {foo.bar} :oops:

Posted: Tue Dec 16, 2008 9:57 am
by Wladimir Palant
That's what $tag is meant for - so that things can be crammed into it without revising the filter syntax every time.

Posted: Tue Dec 16, 2008 4:14 pm
by Adblock Plus Fan
Dipole Moment wrote:match-url

Code: Select all

{foo.org} || /bar.asp$/ >> /quux.js$/
You're thinking very far ahead there with regexp usage for url restriction, it's uncertain if we will even have this url restriction feature ever. But in the event that we get this feature, I don't see what's so bad about simply extending the current syntax.

Code: Select all

/quux.js$/$domain=foo.org,url=/bar.asp$/
Something like this should pretty much match your filter. And it looks less confusing in my opinion.

For now, domain restriction looks like it's enough to fit our needs.
Wladimir Palant wrote:I would like to follow the syntax of element hiding rules but comma is already reserved as an option separator which is too bad.
Is it realistic that we get a foo.com/ad$url= capability in the future?

If it is, then it may be better to reserve the pipe symbol for marking the end/beginning of the url restriction.

I don't know, maybe.