Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
working safari prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce committed Apr 7, 2019
1 parent 720fed5 commit 932c3f2
Show file tree
Hide file tree
Showing 16 changed files with 935 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Safari/BlockerExtension/BlockerExtension.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
22 changes: 22 additions & 0 deletions Safari/BlockerExtension/ContentBlockerRequestHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ContentBlockerRequestHandler.swift
// BlockerExtension
//
// Created by Bruce Roettgers on 07.04.19.
// Copyright © 2019 Dirk Hulverscheidt. All rights reserved.
//

import Foundation

class ContentBlockerRequestHandler: NSObject, NSExtensionRequestHandling {

func beginRequest(with context: NSExtensionContext) {
let attachment = NSItemProvider(contentsOf: Bundle.main.url(forResource: "blockerList", withExtension: "json"))!

let item = NSExtensionItem()
item.attachments = [attachment]

context.completeRequest(returningItems: [item], completionHandler: nil)
}

}
37 changes: 37 additions & 0 deletions Safari/BlockerExtension/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>BlockerExtension</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.Safari.content-blocker</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ContentBlockerRequestHandler</string>
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 Dirk Hulverscheidt. All rights reserved.</string>
<key>NSHumanReadableDescription</key>
<string>Add a description of what your extension does here.</string>
</dict>
</plist>
11 changes: 11 additions & 0 deletions Safari/BlockerExtension/blockerList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"action": {
"type": "block"
},
"trigger": {
"url-filter": ".*",
"resource-type": ["script"]
}
}
]
Loading

0 comments on commit 932c3f2

Please sign in to comment.