Content blockers are easy. Content blockers are hard.

Content blockers are easy. Content blockers are hard.

So today, Mr. Crumble — Cocoon's latest app — is out. It's a content blocker for iOS 9 but unlike other content blockers it's not bothered about ads but instead it targets those annoying EU cookie banners.

Building a content blocker is both easy and hard at the same time. Wait what?

What I mean by that is building the the actual app couldn't be easier. It's basically a shell with a background task to fetch updates from a database every few hours. Now that's where the hard part is… Assembling a database.

Assembling a database

Apple allows content blockers two options: to block or to hide content. Blocking content will stop an entire URL for even being able to resolve. Safari will redirect it to about:blank. Hiding content forcefully hides the element using CSS and display: none;.

In building a database for Mr. Crumble we used a combination of the two. All cookie banners use some form of JavaScript to bin it off when someone clicks the pointless "accept" button.

Building a database was tricky but we started with targeting the most popular WordPress plugins, jQuery plugins and Magento extensions. We then looked at some of the most popular sites in the UK found some truly disgusting implementations. I think H&M is my personal favourite.

Now that we've got a couple of hundred rules in place that seem to block the majority of this things, the plan is to open the database up. We want to port Mr. Crumble to Safari on the Mac as well as make the rules compatible with AdBlock Plus.

Oh, and if you want to include Mr. Crumble in your app/project, talk to me ✌️

Come Say Hello! Drop me an email, follow me on Twitter, or check out Cocoon (you totally should, we're doing some cool stuff over there).

About Stephen Radford

Software Engineer. I take a few photos when I'm not stuck behind a keyboard too.

Leicester, UK