Hello,
I'd love to start building something but can't find the documentation. Sample code I found isn't enough.
Hello,
I'd love to start building something but can't find the documentation. Sample code I found isn't enough.
Yes indeed images blocking is working 🙂
Still no script blocking.. maybe in next beta 😝
Thanks for your time so far!
I don't think this is working for me, am I doing something wrong?...
I create a new iOS app (single-page), then add a content blocking extension. The json file has the default rule that blocks the gold icon on the webkit.org page. Then I run the extension's scheme, select Safari from the list, I go to webkit.org, and the logo is displayed normally. (I'm testing on the simulator.) The extension is also automatically turned on in the settings (as a matter of fact, I can't even turn it off if it's running).
There also doesn't seem to be any way to see errors in the extension - if I make the JSON invalid, it works exactly the same (i.e. it doesn't work).
Ok, here's the solution: I haven't realized that you need to switch the extension off and on in the Preferences to make Safari reload it after you build & run it. I think that didn't even work in beta 1...
So there are two ways you can handle it:
1) Run the app or the extension, Cmd+Shift+H to the Preferences app, turn the extension off and on, Cmd+Shift+H back to Safari, reload the page.
2) In your main app, import SafariServices and run this at startup:
SFContentBlockerManager.reloadContentBlockerWithIdentifier("foo.bar.my.ContentBlocker", completionHandler: nil)
(obviously only in debug mode). Then debug by running your main app instead of the extension, and just Cmd+Shift+H directly to Safari and then reload the page.