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?