Creating a Content Blocker

Post Reply
Posts: 50
Joined: Mon Aug 19, 2019 8:44 am

Creating a Content Blocker

Post by hojoos » Wed Dec 16, 2020 11:50 pm

Content Blockers are app extensions that you build using Xcode. They indicate to Safari a set of rules to use to block content in the browser window. Blocking behaviors include hiding elements, blocking loads, and stripping cookies from Safari requests.

You use a containing app to contain and deliver a Content Blocker on the App Store. The containing app defines the context provided to the extension and initiates the extension life cycle by sending a request in response to a user action.

When the Content Blocker is launched, it communicates with its containing app through a set of shared resources, and it communicates directly with Safari.

Image showing a Content Blocker communicating with various resources.

Apps tell Safari in advance what kinds of content to block. Because Safari doesn't have to consult with the app during loading, and because Xcode compiles Content Blockers into bytecode, this model runs efficiently. Additionally, Content Blockers have no knowledge of users' history or the websites they visit.

Add the Extension Target to Your Containing App
Choose File > New > Target and select Content Blocker Extension. Give your Content Blocker a name.

Image showing the Content Blocker Extension target selected.

Add Behaviors to Your Content Blocker
In your Xcode project, open the folder with the same title as your Content Blocker. This folder contains the action request handler and a JSON file, along with a property list file and an entitlements file. Open the blockerList.json file.

In the JSON file, write rules to define content-blocking behaviors. Each rule is a JSON object containing action and trigger dictionaries. The action tells Safari what to do when the trigger is matched. The trigger tells Safari when to perform the corresponding action. Content Blockers are JSON arrays of these rules.

Posts: 49
Joined: Sat May 18, 2019 8:54 pm

Re: Creating a Content Blocker

Post by doberso » Thu Dec 17, 2020 5:34 pm

What app do you think the best? I have come across a free version of such software . Have you ever heard of it or used it? I suppose it works according the algorithm you have described here. I think I will give it a try. If you have a better option to offer, please let me know. I will gladly test several applications to choose from.

Posts: 4
Joined: Thu Jan 07, 2021 12:28 am
Location: Beaumont, TX

Re: Creating a Content Blocker

Post by GaryWeiss » Thu Jan 07, 2021 12:40 am

I don’t think that makes sense, considering what competitors are on the market.

Post Reply