Safari OS X "block-cookies" content blocking rule

303 views Asked by At

I'm trying to create a simple extension for Safari in OS X that whitelists domains for setting cookies. The documentation indicates that this is possible with the "block-cookies" action type. When I try to use it, however, it does nothing. I'm testing here, and the site is able to set cookies no matter what kind of rule I use or how broad or specific my url trigger is.

The extension is loaded and functioning. If I change the action to something else, it works.

When I do this, the "topbar" div is hidden:

[{"trigger": {"url-filter": ".*whatarecookies.com.*"},"action": {"type": "css-display-none","selector": "#topbar"}}]

When I do this the entire page fails to load:

[{"trigger": {"url-filter": ".*whatarecookies.com.*"},"action": {"type": "block"}}]

When I do this, nothing is blocked:

[{"trigger": {"url-filter": ".*whatarecookies.com.*"},"action": {"type": "block-cookies"}}]

Safari must at least be accepting my block-cookies rule, because if I change it to something invalid, it gives me an error that, "JSON compilation failed." Like this:

[{"trigger": {"url-filter": ".*whatarecookies.com.*"},"action": {"type": "blockcookies"}}]

Am I not using the "block-cookies" action correctly? Or is it bugged?

1

There are 1 answers

0
mike On BEST ANSWER

I revisited this and figured out what the problem was (is): Safari's "block-cookies" action does block cookies, but only those that are set via HTTP headers. The site I was testing on sets its cookies through javascript, which content blocking can't do anything about.

Content blocking also has a "script" filter, but like the "block-cookies" action, it's extremely limited. Since the test site sets its cookie through an inline script, enabling a "script" filter still won't block it.